JSF viewscope 值未正确显示在视图中
我在 ViewScope 下有一个托管 bean。它里面有一个实例变量。
MetaData 对象有一个 inputItem 对象 List。
@ManagedBean
@ViewScoped
public class ConBean implements Serializable {
private MetaData metadata;
@PostConstruct
@SuppressWarnings("unchecked")
public void init() throws IOException {
this.metadata = new MetaData ();
}
public void proc(){
List<InputItem> inputs= new ArrayList<InputItem>();
inputs.add(***** code to populate the inputItem List);
//after populating, inputs added to the metadata
metadata.setInputs(inputs);
}
//getters & setters
}
在我的 JSF 中,输入列表填充在 UI 重复中。
<div id="inputplaceholder">
<ui:repeat value="#{conBean.metaData.inputs}" var="content">
</ui:repeat>
</div>
div inputplaceholder 使用 richfaces 民意调查定期更新。
<a4j:poll id="poll" interval="12000" action="#{conBean.proc}"
execute="@form" render="inputplaceholder"/>
我遇到的问题是,即使 inputItems 在 proc() 方法内正确设置为元数据对象,当视图呈现/部分更新时,它不会在 UI 中突出显示。所以部分更新不起作用。我尝试移动
this.metadata = new MetaData (); 在 proc 方法内部但没有运气。
非常感谢任何想法和帮助。
谢谢 ...
I have a managed bean under ViewScope. It has an instance variable inside it.
MetaData object has a inputItem object List.
@ManagedBean
@ViewScoped
public class ConBean implements Serializable {
private MetaData metadata;
@PostConstruct
@SuppressWarnings("unchecked")
public void init() throws IOException {
this.metadata = new MetaData ();
}
public void proc(){
List<InputItem> inputs= new ArrayList<InputItem>();
inputs.add(***** code to populate the inputItem List);
//after populating, inputs added to the metadata
metadata.setInputs(inputs);
}
//getters & setters
}
in my JSF , input list is populated inside a UI repeat.
<div id="inputplaceholder">
<ui:repeat value="#{conBean.metaData.inputs}" var="content">
</ui:repeat>
</div>
the div inputplaceholder is periodically updated using a richfaces poll.
<a4j:poll id="poll" interval="12000" action="#{conBean.proc}"
execute="@form" render="inputplaceholder"/>
The problem that I have is even though inputItems are set to the metaData object correctly inside the proc() method, when the view is rendered/partially updated, it doesn't get highlighted in the UI. so partial update takes no effect. I tried moving
this.metadata = new MetaData ();
inside the proc method but had no luck.
any ideas and help is highly appreciated.
thanks ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
部分渲染真的发生了吗?这是不可能的。也就是说,不存在 ID 为
inputplaceholder
的 JSF 组件。您将其分配给纯 HTML元素。将其替换为完整的 JSF 组件:
此外,由于您在 render 属性中使用了相对 ID,因此它只会扫描同一父命名容器组件中的组件。
就是这样一个,但是具有所需 ID 的组件被放置在其外部。您想改用绝对 ID。假设它位于具有固定 ID 的
内:那么您应该在
render
属性中引用它,如下所示Did the partial render really take place? This is impossible. There is namely no JSF component with the ID
inputplaceholder
. You assigned it to a plain HTML<div>
element. Replace it by a fullworthy JSF component:Also, since you used a relative ID in the
render
attribute, it will only scan for components in the same parent naming container component. The<ui:repeat>
is such one, however the component with the desired ID is placed outside it. You'd like to use an absolute ID instead. Assuming that it's inside a<h:form>
with a fixed ID:then you should be referencing it in the
render
attribute as follows