JSF 2.0:从呈现的组件到托管bean失败的Ajax调用 [英] JSF 2.0 : Ajax call from the rendered component to managed bean failure

查看:74
本文介绍了JSF 2.0:从呈现的组件到托管bean失败的Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JSF2.0进行Iam,其中Iam根据该页面上的用户活动使用ajax渲染一组组件.这很好,但是,在渲染组件之后,iam根据所渲染的用户活动再次执行ajax调用组件这是我的ajax调用失败的地方.我在两种情况下都执行了相同的实现,但不知道为什么失败.有人可以帮我找出错误吗?

Iam using JSF2.0 wherein Iam rendering a group of components using ajax based on a user activity on that page .This works fine however,after the component gets rendered, iam performing an ajax call again based on user activity within this rendered component This is where my ajax call is failing .I have done the same implementation in both scenarios but no idea why its failing .Could someone help me figure out the error ?

以下是代码:

第一个ajax调用:

 <h:commandLink id="addMultiple" value="Add" >                  
<f:ajax execute="addMultiple" render="additionalField " listener="#{Bean.doAddMultiple}"/>
</h:commandLink>

渲染组件:

 <h:panelGroup id = "additionalField"   > 
 <h:outputText  value="New Field:"  rendered="#{Bean.multiple eq 'true'}" />
 <h:inputText style="width:10%" value="#{Bean.Number}"  rendered="#{Bean.multiple eq 'true'}" />
<h:commandButton id="add" value = "Add"  rendered="#{Bean.multiple eq 'true'}">
<f:ajax event="click" execute="add" render="textBoxes" listener="#{Bean.doaddTextboxes}"/>  
</h:commandButton>
</h:panelGroup>

上述组件呈现良好状态.我有相同形式的"textBoxes"组件,以及以AJaxBehaviour事件作为参数的托管bean方法.但是,这里的问题是第二个AJAX调用甚至没有触发.这里的问题是什么?

The above component is rendered fine . I have the "textBoxes" component in the same form as well as the managed bean method taking AJaxBehaviour event as the parameter also .But the issue here is the second AJAX call is not even fired .what is the issue here ?

推荐答案

将其更改为 @ViewScoped ,一般而言,最好使用atlesat @ViewScoped 完成ajax.导致在每次提交时创建新的bean实例...

Change it to @ViewScoped , in general ajax better be done with atlesat @ViewScoped... cause new instance of the bean created upon each submit...

也请查看以下 JSF-Ajax调用-此代码有什么问题?和此此外,请在此处查看 BalusC Arjan Tijms 的答案JSF-

Also , take a look at BalusC and Arjan Tijms answers over here JSF - Can @PostConstruct block setter method by using an ajax call?

这篇关于JSF 2.0:从呈现的组件到托管bean失败的Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆