我想实现一个使用JSF的场景。我有一个commandExButton
,当用户点击这个按钮“A”时,它显示panelDialog
其中包含selectManyCheckBox
项目。我通过解析一个不断更新的文件在后端bean中生成这些项目。我想要的是,只要我点击这个按钮“A”,我应该通过后端bean解析文件来获得最新的selectItems。但是,我得到它与第一次呈现页面时生成的selectItem相同。所以截至目前我有一个解决方法,其中我包括一个刷新按钮,实际刷新页面,然后用户单击“A”通过解析当前文件的内容来获取最新的selectItem。但是,无论如何,无需添加新的按钮和使用现有的按钮,它是可行的吗?如何动态刷新h:selectManyCheckbox selectItems
下面是我使用
<td>
<hx:commandExButton id="preferenceButton" styleClass="form" value="#{nls.preferenceLink}"
title="#{nls.preferenceLinkTitle}" type="submit" />
</td>
<td>
<h:form id="PrefForm" rendered="#{Test.isCurrent}">
<hx:panelDialog type="modal" id="preferenceSet" styleClass="panelDialog" for="preferenceButton"
title="#{nls.preferenceDialogTitle}">
<h:outputText styleClass="panelStartMessage" style="display:block;"
value="#{nls.preferenceDialogWindowText}" />
<h:panelGroup rendered="#{Test.hasSelectItem }"
style="display:block;width:300px;height:360px;overflow:auto;" styleClass="panelGroup"
id="prefPanelGroup">
<h:selectManyCheckbox value="#{Test.selectedItems}" layout="pageDirection">
<f:selectItems value="#{Test.selectItems}" />
</h:selectManyCheckbox>
</h:panelGroup>
<hx:panelBox styleClass="information_box" id="noCommandWindow" layout="lineDirection"
rendered="#{!Test.hasSelectItem }">
<h:outputText styleClass="outputText" id="cmdInfo" value="#{nls.noCommands}" />
</hx:panelBox>
<hx:panelBox id="buttonBox1" styleClass="panelStartBox" layout="lineDirection">
<hx:commandExButton id="submitPref" styleClass="commandExButton" type="submit"
value="#{nls.submit}" action="#{Test.action}">
<hx:behavior event="onclick" behaviorAction="hide" targetAction="preferenceSet"
id="behaviorSubmitPref" />
</hx:commandExButton>
<hx:commandExButton id="CancelPref" styleClass="commandExButton" type="submit"
value="#{nls.cancel}" action="Test">
<hx:behavior event="onclick" behaviorAction="hide" targetAction="preferenceSet"
id="behaviorCancelPref" />
</hx:commandExButton>
</hx:panelBox>
</hx:panelDialog>
</h:form>
</td>
守则豆代码:
public class Test{
private List<String> selectedItems;
private List<SelectItem> selectItems;
public List<SelectItem> getSelectItems() {
// populate the selectItem here...
}
}
Hi BalusC,谢谢你的回复。我当前的bean只是会话范围。我尝试将action和actionListener方法绑定到selectItems,然后在该面板对话框中显示最新的复选框选择项。但按钮根本不调用bean方法,而在这里我实际上被卡住了。有没有其他方法? – 2010-08-25 05:30:55
“在其构建期间填充它并添加一个像reload()这样的方法 - 那么我应该绑定这个方法的哪个组件?我应该添加另一个按钮并附加此刷新按钮吗?但在这种情况下,它会刷新整个页面,我想避免。我是JSF的新手,所以请忍受我有限的知识,如果我在这里不明白任何东西。 – 2010-08-25 05:31:28