2010-11-18 216 views
0

我有这个不起作用的简单场景:我使用icefaces,并且我有一个带有一些inputTexts和一个提交按钮的简单页面,该按钮将重定向到另一个页面将显示这些inputTexts的值...我的问题是如何从请求中获取这些inputTexts的值并将它们显示在另一个页面中?ICEfaces:如何将参数从一个页面传递到另一个页面

当我在其他页面backbean使用下面的API,我得到持有inputTexts页面的唯一名称:

FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); 

我真的花了很多时间试图让这件事的工作,所以任何帮助将不胜感激.. THx的

我的网页代码:

<ice:form id="form1"> 
<table border="0"> 
    <tbody> 
     <tr> 
      <td><ice:outputText value="Name"></ice:outputText><br></br></td> 
      <td><ice:inputText id="name" value="#{newContest.name}"></ice:inputText></td> 
     </tr> 
     <tr> 
      <td><ice:outputText value="End Date"></ice:outputText></td> 
      <td><ice:inputText id="endDate" value="#{newContest.endDate}"></ice:inputText></td> 
     </tr> 
     <tr> 
      <td><ice:outputText value="private? (only you can see the entries)"></ice:outputText></td> 
      <td><ice:inputText id="private" value="#{newContest.isPublic}"></ice:inputText></td> 
     </tr> 
     <tr> 
      <td><ice:outputText value="Price"></ice:outputText></td> 
      <td><ice:inputText id="price" value="#{newContest.price}"></ice:inputText></td> 
     </tr> 
     <tr> 
      <td><ice:outputText value="Description"></ice:outputText></td> 
      <td><ice:inputTextarea id="description" value="#{newContest.description}"></ice:inputTextarea></td> 
     </tr> 
     <tr> 
      <td><br></br><ice:commandButton value="proceed to payment" style="color:blue" action="#{newContest.createContest}"></ice:commandButton></td> 
     </tr> 
    </tbody> 
</table> 

回答

1

您可以按照以下方式将另一个bean与当前的bean绑定为faces-config.xml中的托管属性。

<managed-bean> 
     <managed-bean-name>newContest</managed-bean-name> 
     <managed-bean-class>com.newContest</managed-bean-class> 
     <managed-bean-scope>request</managed-bean-scope> 

     <managed-property> 
     <property-name>anotherBackingBean</property-name> 
      <property-class>com.AnotherBackingBean</property-class> 
      <value>#{anotherBackingBean}</value> 
    </managed-property>  
    </managed-bean> 


<navigation-rule>  
      <navigation-case> 
      <from-outcome>view-anotherBackingBean</from-outcome> 
      <to-view-id>/jsp/another-page.jspx</to-view-id> 
     </navigation-case> 
    </navigation-rule> 

豆内容

Class NewContest { 

public AnotherBackingBean anotherBackingBean; 

//-- set/get & other methods 

public String redirectToAnotherBackingBean(){ 

     anotherBackingBean.setSomeObject(object); 

     //-- set custom fields 

     return "view-anotherBackingBean"; 
    } 

} 

然后你可以在其中已经在当前Bean设置其他的bean直接使用你的领域。

+0

这对我来说非常好!非常感谢你!只有我还有一个问题,如果将标记添加到导航规则以使后退按钮有效,则该值不会出现在下一页中!那是什么?! – 2010-11-19 08:46:58