【发布时间】:2013-12-01 16:22:51
【问题描述】:
大家好,我有一些输入框,用户可以在其中输入详细信息并提交,这需要进行一些验证,而不是 null 等,这一切正常,但是如果用户有,我有一个导航按钮可以回家错误地来到这个页面,但是当用户按下这个按钮时,它也会调用验证并要求用户输入详细信息,这对于主页按钮是不好的,有什么办法我不能运行验证用户按下此按钮?这是一个primefaces命令按钮
这是代码,如果我使用链接,我可以很好地导航,但为了用户体验,我宁愿使用命令按钮
<h:form>
<p:growl id="growl" showDetail="true" sticky="true" />
<!--ajax messages working now -->
<p:panel header="Enter details">
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.CreateUserdetailsLabel_id}" for="id" />
<h:inputText id="id" value="#{userdetailsController.selected.id}" title="#{bundle.CreateUserdetailsTitle_id}" required="true" requiredMessage="#{bundle.CreateUserdetailsRequiredMessage_id}"/>
<h:outputLabel value="#{bundle.CreateUserdetailsLabel_username}" for="username" />
<h:inputText id="UserName" value="#{userdetailsController.selected.username}" title="#{bundle.CreateUserdetailsTitle_username}" required="true"
requiredMessage="Username is required"
label="UserName" >
<f:validator validatorId="richard.validator.UserNameValidator" />
</h:inputText>
</h:panelGrid>
<br />
<p:commandButton action="#{userdetailsController.create}" value="#{bundle.CreateUserdetailsSaveLink}" update="growl"/>
<br />
<br />
<p:commandButton action="#{userdetailsController.prepareList}" value="#{bundle.CreateUserdetailsShowAllLink}" immediate="true"/>
</p:panel>
<br />
<br />
<!--
Trying to use a command button to navigate however it is requiring the user enter details first and this is not acceptable so looking for a solution
<p:commandButton action="{naviagation.buttonHome}" value="Home" icon ="ui-icon-home" ajax="False"/>
<p:commandButton action="{bundle.ListUserdetailsIndexLink}" value="List of all current records" icon ="ui-icon-person" ajax="False"/>
-->
<h:link outcome="/index" value="#{bundle.ListUserdetailsIndexLink}"/>
</h:form>
谢谢
【问题讨论】:
标签: jquery validation jsf primefaces