0

我想用最后检查的数据库的角色填充角色数据表。我该如何实施?

public class Database implements Serializable {
    private List<Role> roles;
    private String name;
    private boolean selected;
    ...
}

public class Role implements Serializable {
    private String name;
    ...
}  

data.xhtml看起来像这样

...
<p:dataTable id="databases" var="database" value="#{dataBean.databases}" >  
    <p:column>  
        <p:selectBooleanCheckbox value="#{database.selected}">  
            <p:ajax update="roles, databases" immediate="true" />  
        </p:selectBooleanCheckbox>  
    </p:column>  
    <p:column headerText="Databases">  
        <h:outputText value="#{database.name}" />  
    </p:column>  
</p:dataTable>  

<p:dataTable id="roles" var="role" value="#{dataBean.roles}" >                
    <p:column headerText="Roles">
        <h:outputText value="#{role.name}" />
    </p:column>
</p:dataTable>
4

1 回答 1

1

数据.xhtml

<p:dataTable id="databases" var="database" value="#{dataBean.databases}" > 

<p:selectBooleanCheckbox value="#{database.selected}">  
    <f:ajax execute="@this" listener="#{dataBean.updateRoles}" />
    <f:attribute name="selRec" value="#{database}" />
</p:selectBooleanCheckbox> 

数据豆

...

public void updateRoles(AjaxBehaviorEvent event) {  
    //database is theobject in the current row 
    Database database = (Database) event.getComponent().getAttributes().get("selRec");       
}   
...   
于 2012-04-19T07:50:18.993 回答