我创建了一个名为loginRegisterTemplate.xhtml的facelet模板。当我在一个模板客户端中使用它时,我将它放在里面,托管bean中的方法不会被调用。没有模板,按钮工作正常。这是为什么发生?<h:commandButton> not working <ui:define>
<ui:composition template="resources/css/faceletsTemplates/loginRegisterTemplate.xhtml">
<ui:define name="top">
Login Page
</ui:define>
<ui:define name="content">
<div align="center">
<h:panelGrid columns="3" columnClasses="rightalign,leftalign,leftalign">
<h:outputLabel value="Username:" for="userName"/>
<h:inputText id="userName" label="Username" required="true" value="#{loginBean.userName}" />
<h:message for="userName" />
<h:outputLabel value="Password:" for="password"/>
<h:inputText id="password" label="Password" required="true" value="#{loginBean.password}" />
<h:message for="password" />
</h:panelGrid><br/>
<h:button value="Back to Home" outcome="home"/>
<h:commandButton id="login" value="Login" action="#{loginBean.doLogin}"/>
</div>
</ui:define>
</ui:composition>
</h:body>
它旁边的简单<h:button>
工作正常。
这里是我的模板文件的主体:
<h:body>
<div id="top">
<ui:insert name="top">Top</ui:insert>
</div>
<div id="content" class="center_content">
<ui:insert name="content">Content</ui:insert>
</div>
</h:body>
我已经在这里看了:h:commandLink/h:commandButton is not being invoked但我找不到这问题会导致。
谢谢!
非常感谢!我真的不知道我是如何错过的,而且我一直在寻找更复杂的解决方案! – BrainArchitect