tags:

views:

43

answers:

1

Hello All! i have one trouble with beanscope in one page i know if i want redisplay in one page i can use viewscope but now i want get value form datatable pass from dialog to dialog in one page and i use sessionscope. I can get this value but the first select the value not show, i must press f5 (refresh) page the value is show, i know it mean in session scope data pass from one page to another page but now i want pass data in 1 page throws dialog i user primepface dialog how can i do it? it mean when i on click to image the dialog one display data table list and when i click to edit button it call dialog two display details one of data list (details instance of object). I can do it but i must refresh page (reload page) how can i do it , don't refresh page?

i want to use SessionScoped and i want id pass from dialog to dialog , and dont want refresh page for session scoped maintain data how can i do it?

my Code JSF

<p:dialog header="Category" widgetVar="cate" width="600">
    <f:view>
        <h:form>
            <p:dataTable value="#{catController.allCate}" var="item" paginator="true" rows="10"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} ">
              <p:column>
                    <f:facet name="header">
                        <h:outputText value="Category name"/>
                    </f:facet>
                    <h:outputText value="#{item.cateName}"/>
                </p:column>
                <p:column style="width: 10px">
                    <f:facet name="header">
                        <h:outputText value=""/>
                    </f:facet>
                    <p:commandButton action="#{catController.showDetails(item)}"  onclick="editcate.show()" style="cursor: pointer;width: 10px; height: 15px;" image="edit"/>
                </p:column>
            </p:dataTable>
        </h:form>
    </f:view>

</p:dialog>







    <p:dialog header="Edit category" widgetVar="editcate" height="130" width="300">
    <f:view>
        <h:form>

            <h:panelGrid columns="2">
                <h:outputLabel value="" for="cateId" />
                <h:inputHidden id="cateId" value="#{catController.details.cateId}" />
                <h:outputLabel value="Category Name" for="cateName" />
                <h:inputText id="cateName" value="#{catController.details.cateName}" title="CateName" required="true" requiredMessage="The CateName field is required."/>
            </h:panelGrid>
        </h:form>
    </f:view>


</p:dialog>

and my backing bean

package com.mcgraw.controller;

import com.DAO.CategoryDAO;
import com.entity.Category;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


/**
 *
 * @author Kency
 */
@ManagedBean
@SessionScoped
public class CatController implements Serializable{
    @EJB
    private CategoryDAO categoryDAO;
    private Category cate;







    /** Creates a new instance of CatController */
    public CatController() {
        cate = new Category();
    }


     public Category getCate() {
        return cate;
    }

    public void setCate(Category cate) {
        this.cate = cate;
    }


    // lay toan bo danh sach category
    public List<Category> getAllCate(){
        return categoryDAO.retrieveAllCat();
    }

    public void showDetails(Category cat){
        this.cate = cat;


    }
    //tra ve thong tin chi tiet cua 1 category
    public Category getDetails(){
        //return categoryDAO.findByCatID(cate.getCateId());
        return cate;
    }




}
A: 

You use @ViewScoped and reRender (update) the dialog.

<p:commandButton update="dialog" action="#{catController.showDetails(item)}"  onclick="editcate.show()" style="cursor: pointer;width: 10px; height: 15px;" image="edit"/>

and add id to the dialog:

<p:dialog id="dialog" >
   ...
  </p:dialog>
Odelya
it work well but when i click on command button it show dialog with id "dialog" about 2s and close that dialog ! how can i keep it, dialog with id = "dialog" ? i user sessionscoped, use viewscope it not show data >.< but i must refresh page with session scope
Kency
Now i can solve it , here is solution http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf many thank you
Kency