更新后的渲染列表

时间:2018-12-12 14:16:34

标签: ajax jsf primefaces

我想从列出所有配置中添加项目以列出当前配置

<h:form id="formId">
    <h:outputText value="All Configurations:"/>
    <b:dataTable id="allConfigurations" var="rowItem" value="#{administratorManager.allConfigurations}" 
        paginated="true" searching="true" lang="true">
        <b:dataTableColumn value="#{rowItem.description}" />
        <b:dataTableColumn value="#{rowItem.description}" />
        <b:dataTableColumn label="Actions">

            <h:commandLink value="Add">        
                <f:ajax event="click" listener="# {administratorManager.addConfiguration(rowItem)}" 
                    render=":formId:result, allConfigurations, currentConfigurations"/>
            </h:commandLink>
        </b:dataTableColumn>
     </b:dataTable>

    <h:panelGroup id="result">
         <h:outputText value="#{administratorManager.currentConfigurations}" rendered="true" />

            #{administratorManager.currentConfigurations}
    </h:panelGroup>
</h:form>

如果我重新加载页面,则项目将显示在列表中。

ManagedBean:

@Named(value = "administratorManager")
@SessionScoped
public class AdministratorManager implements Serializable {
    ...
    public void addConfiguration(Configuration selectedConfiguration){
        logger.warning("I WAS EXECUTED, ADDCONFIGURATIONS");
        allConfigurations.remove(selectedConfiguration);
        currentConfigurations.add(selectedConfiguration);
        logger.warning(String.valueOf(currentConfigurations.size()));
    }

0 个答案:

没有答案