如何在Bean

时间:2016-04-27 17:34:28

标签: jsf primefaces

我正试图将selectOneMenu的值从primefaces变为Bean。它返回旧值而不是新值。

ManagedBean

public void doSetPrivilege( AjaxBehaviorEvent event)
 {
        SelectOneMenu selectOneMenu =  (SelectOneMenu) event.getSource();
        String value = selectOneMenu.getValue().toString();
        System.out.println(value);
 }

我从数据库

获取属性privilegeApp

public Privilege getPrivilegeApp(){

            TreeTable treeTable = new TreeTable();
            treeTable = (TreeTable) FacesContext.getCurrentInstance().getViewRoot().findComponent(":idform:apps");

            data = treeTable.getRowNode();

            if (data.getType().equals("type1")) {
                Application app = applicationService.loadApplicationByDesignation(data.getData().toString());

                privilegeApp = privilegeService.getPrivilegeApplicationUtilisateur(getUtilisateur().getIdUtilisateur(),
                        app.getIdApplication());
            } 

           return privilegeApp;
        }

XHTML

  <p:treeTable id="apps" value="#{treeTableTest3.root}" var="app" selectionMode="single" selection="#{treeTableTest3.selectedNode}" >
   <p:column headerText="Designation" >
    <h:outputText value="#{app}" />
   </p:column>
     <p:column headerText="Etat" >  
    <center> 
            <p:selectOneMenu value="#{treeTableTest3.privilegeApp.etat}" id="etat" style="width:100px; size:30px; float:center;">
            <f:selectItem itemLabel="::Etat::" itemValue="#{null}"/>
            <f:selectItems value="#{treeTableTest3.etats}" 
             var="etat"
             itemValue="#{etat}" >
            </f:selectItems>
            <p:ajax event="change" listener="#{treeTableTest3.doSetPrivilege}" process="@all"/>
            </p:selectOneMenu>
            </center>
        </p:column> 

   </p:treeTable>

感谢您的帮助

0 个答案:

没有答案