gpt4 book ai didi

java - a4j :commandLink and a4j:commandButton not working properly 时 Richfaces 4 和 JSF2.0 的问题

转载 作者:行者123 更新时间:2023-12-04 06:20:36 25 4
gpt4 key购买 nike

我有一个简单的登录表单。当我单击登录时,a4j:commandButton 运行良好,包含登录表单的位置成为带有注销链接的用户信息。但是,当我单击“注销”链接时,ajax 只显示状态,但如果我再次单击它,则不会发生任何事情,用户将按照我想要的方式注销

这意味着我必须单击两次才能注销用户???发生什么事 ?

<a4j:outputPanel id="login_wrapper" ajaxRendered="true">
<h:form id="fm_logged" rendered="#{mAccount.loggedIn}">
<h3>User Information</h3>
<a4j:status name="login_form_status">
<f:facet name="start">
<h:graphicImage library="images" name="ajax-loader.gif" />
</f:facet>
</a4j:status>

<h6><h:outputText value="Welcome! #{mAccount.acc.name}" /></h6>
<ul class="list1">
<li><h:link value="User Account Control" outcome="/pages/management/buyer_home" style="text-decoration:none;"></h:link></li>
<li><a4j:commandLink id="logout" status="login_form_status" actionListener="#{mAccount.Logout}" value="Logout" style="text-decoration:none;"></a4j:commandLink></li>
</ul>
</h:form>
<h:form id="login-form" class="login-form" rendered="#{!mAccount.loggedIn}" >
<h3>Login Form</h3>
<a4j:status name="login_form_status">
<f:facet name="start">
<h:graphicImage library="images" name="ajax-loader.gif" />
</f:facet>
</a4j:status>
<h:outputText value="Wrong username or password" rendered="#{mAccount.wrongUsername}" style="color:red;" />
<fieldset>
<div class="field">
<label>Email: </label><h:inputText value="#{mAccount.acc.email}" />
</div>
<div class="field">
<label>Password</label><h:inputSecret value="#{mAccount.acc.password}" />
</div>
<div class="field">
<label class="alt">Remember me</label><h:selectBooleanCheckbox value="#{mAccount.rememberMe}" />
</div>

<ul>
<li><h:link outcome="forgot_password">Forgot your password?</h:link>
</li>
<li><h:link outcome="registration">Create an account.</h:link>
</li>
</ul>

<div class="wrapper">
<a4j:commandButton id="login" status="login_form_status" value="Login" actionListener="#{mAccount.Login}"> </a4j:commandButton>
</div>
</fieldset>
</h:form>
</a4j:outputPanel>

最佳答案

你有 2 个表格。当一个表单使用 ajax 重新渲染另一个表单时,另一个表单的 View 状态将丢失。在您刷新表单之前,JSF 不会处理表单提交(这是第一次点击所做的,因此第二次点击才有效)。

您需要重新排列 ajax 重新呈现逻辑,以便一个表单永远不会重新呈现整个另一个表单,而只重新呈现其内容。因此,在另一个 <h:form> 中添加一些包含组件与 id然后您使用 reRender 引用它来自提交表单的 ajax 命令链接/按钮的属性。

关于java - a4j :commandLink and a4j:commandButton not working properly 时 Richfaces 4 和 JSF2.0 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6634541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com