0

我有四个位置可供选择,显示为“selectOneRadio”。当我选择一个位置时,当我单击命令链接之一时,bean 会得到更新。

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">
    <ui:define name="content">
    <h:form>
    <h:commandLink action="#{wrapper.goBack}" value="GESTERN"></h:commandLink>
    ---------
    <h:commandLink action="#{wrapper.goForward}" value="MORGEN"></h:commandLink>
    <br />
    <h:selectOneRadio id="locationSelection" value="#{wrapper.actualLocation}" >
        <f:selectItems value="#{wrapper.allLocations}" var="actualLocation" ></f:selectItems>
    </h:selectOneRadio>
</h:form>    
</ui:define>
</ui:composition>

当我想在单击单选按钮时立即更改支持 bean 时,我必须更改什么?

非常感谢任何帮助。

4

1 回答 1

0

要在单击时执行提交,您需要使用 Ajax。

对于 JSF 1.2,这意味着您需要为 JSF 使用众多 ajax 框架之一(如带有 A4J 的 Richfaces)。

对于 JSF 2.x,它是内置的。

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">
    <ui:define name="content">
    <h:form>
    <h:commandLink action="#{wrapper.goBack}" value="GESTERN"></h:commandLink>
    ---------
    <h:commandLink action="#{wrapper.goForward}" value="MORGEN"></h:commandLink>
    <br />
    <h:selectOneRadio id="locationSelection" value="#{wrapper.actualLocation}" >
        <f:selectItems value="#{wrapper.allLocations}" var="actualLocation" ></f:selectItems>
        <f:ajax event="click" />
    </h:selectOneRadio>
</h:form>    
</ui:define>
</ui:composition>

这将在单击单选按钮后立即提交表单。您还可以指定要处理的字段以及要重新呈现的字段。

见: http: //mkblog.exadel.com/2010/04/learning-jsf-2-ajax-in-jsf-using-fajax-tag/

于 2012-06-15T13:46:09.643 回答