多次重复使用同一页面

编程入门 行业动态 更新时间:2024-10-26 00:27:15
本文介绍了多次重复使用同一页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以多次重复使用一个页面连接到不同的对象?

Is it possible to reuse one page multiple times attached to different objects?

我有一个页面,你可以输入个人信息(姓名,地址,社交号码, ...)连接到一个bean:前景。 在某些情况下,我必须收集相关的个人信息。信用评分的例子(一个人和一个担保人)。

I have a page were you can input personal information (name, address, social number, ...) connect to one bean: prospect. In some occasions I must gather linked personal information. example for credit scoring (a person and a guarantor).

所以我想用2个包括。但是,如何确保include1保存person1的信息,include2保存person2的信息?

So I wanted to use with 2 includes. But how can I make sure include1 holds the information for person1 and include2 holds the information for person2?

<rich:tabPanel id="creditScoreTab" switchType="client" > <rich:tab id="mainContractor" > <ui:include src="includes/prospect.xhtml" /> </rich:tab> <rich:tab id="guarantor"> <ui:include src="includes/prospect.xhtml" /> </rich:tab> </rich:tabPanel>

and facescontext

and facescontext

<managed-bean> <managed-bean-name>prospect</managed-bean-name> <managed-bean-class>be.foo.Prospect</managed-bean-class> <managed-bean-scope>view</managed-bean-scope> </managed-bean>

我找到了2种可能的解决办法: -duplicate页面并在面孔中定义2个bean -config(指向同一个java类) -do不使用tabpanel和include,但输入person1信息,然后保存并加载person2信息并保存person2。

I found 2 possible work arounds: -duplicate the page and define 2 beans in faces-config (pointing to the same java class) -do not use tabpanel and include, but enter person1 info , then save it and load person2 info and save person2.

解决方法1的负面影响是它保持两次相同的代码。解决方法2的负面观点是它不是那么'酷'(ux观点)

Workaround1 negative point is that it is maintaining the same code twice. Workaround2 negative point is that it is not so 'cool' (ux point of view)

推荐答案

你可以使用<ui:param> 将参数传递给 < ui:include> :

You can use <ui:param> to pass parameters to <ui:include>:

<rich:tabPanel id="creditScoreTab" switchType="client" > <rich:tab id="mainContractor" > <f:subview id="mainContractorView"> <ui:include src="includes/prospect.xhtml"> <ui:param name="person" value="#{bean.person1}" /> </ui:include> </f:subview> </rich:tab> <rich:tab id="guarantor"> <f:subview id="guarantorView"> <ui:include src="includes/prospect.xhtml"> <ui:param name="person" value="#{bean.person2}" /> </ui:include> </f:subview> </rich:tab> </rich:tabPanel>

通过上面的示例,在每个包含中,所需的人将以的形式提供#{人} 。这些< f:subview> 标记用于防止重复的组件ID错误,因为它们最终位于相同的 UINamingContainer 父级中。

With the above example, in each include the desired person will be available as #{person}. Those <f:subview> tags are to prevent duplicate component ID errors because they end up within the same UINamingContainer parent.

更多推荐

多次重复使用同一页面

本文发布于:2023-11-16 19:58:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重复使用   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!