查看
<h:form id="main_form">
<p:inputText id="title" required="true" label="Title" value="#{myBean.myLink.title}" immediate="true" />
<p:selectOneMenu id="scope" required="true" label="Scope" value="#{myBean.myLink.scope}" immediate="true" >
<f:selectItem itemLabel="Please choose" itemValue="" />
<f:selectItems value="#{myBean.availableScopes}" id="selScope"/>
</p:selectOneMenu>
<p:inputText id="link" required="true" label="URL" value="#{myBean.myLink.link}" immediate="true">
<p:ajax event="blur" update="msgLink" listener="#{myBean.checkUrl}" />
</p:inputText>
... msgLink and other (required) elements
... submit button
</h:form>
托管Bean
@Component("myBean")
@Scope("session")
public class MyBean implements Serializable {
private Link myLink;
private Map<String, String> availableScopes;
public MyBean() {
this.availableScopes = new HashMap<String, String>();
this.availableScopes.put("Intranet", "Intranet");
this.availableScopes.put("Internet", "Internet");
}
// setter/getters etc.
public void checkUrl() {
System.out.println(myLink.getTitle()); // works
System.out.println(myLink.getScope()); // DOES NOT work
System.out.println(myLink.getLink()); // works
}
}
inputText
值。不是selectOneMenu
中选择的值。 getExternalContext().getSessionMap().get("scope")
尝试过,但当时SessionMap为空。是否有机会访问组合框的选定值?
由于 吉姆
答案 0 :(得分:4)
<p:ajax>
组件中的<f:ajax>
(和UIInput
)默认执行/处理当前 UIInput
组件({{1} }),而不是其他人。
如果要在调用侦听器方法时执行/处理所有@this
组件,则应在UIInput
(或<p:ajax process>
)属性中指定:
<f:ajax execute>
无关,我想知道所有这些<p:inputText id="title" ... />
<p:selectOneMenu id="scope" ... >
...
</p:selectOneMenu>
<p:inputText id="link" ...>
<p:ajax process="title scope link" ... />
</p:inputText>
属性在这种情况下是如何有用的。你确定你需要它们吗?