我正试图将参数从UI传递到管理bean的服务。值没有被设置为bean属性
<ui>
<p:dialog header="Account Search" widget-var="account Search">
<h:inputText id="account Name" value="#{accountSub.request.accountName}"/>
<p:commandButton id="btnSearch" update="">
<h:inputText id="account Name" value="#{accountSub.request.accountNumber}"/>
<p:commandButton id="btnSearch" update="">
<p:ajax event="click" listener="#{accountSub.process}" update="@widgetVar(resultPanel)">
</p:dialog>
</ui>
管理Bean
@ManagedBean
@VieweScoped
public class AccountSub {
private Account request;
//getter and setter for same
public void process(){
// process logic goes here.
}
}
class Account{
private String accountName;
private String accountNumber;
//getter and setter
}
示例中有几个错误。
- 输入组件Id无效。不应该包含空格。
- Ajax事件'click'不支持
使用如下的form元素
<h:form>
<p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
<h:inputText id="name" value="#{accountSub.request.accountName}"/>
<h:inputText id="number" value="#{accountSub.request.accountNumber}"/>
<p:commandButton id="btnSearch" actionListener="#{accountSub.process}">Click</p:commandButton>
</p:dialog>
</h:form>