多次重复使用同一页面 [英] Reusing the same page multiple times

查看:163
本文介绍了多次重复使用同一页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于多次重复使用同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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