JSF添加< f:param>到数据表 [英] JSF adding <f:param> to datatable

查看:33
本文介绍了JSF添加< f:param>到数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我试图在这里使用f:param将requestid作为参数传递给评论页面.当前正在执行以下操作,但是Managedproperty不能按我的要求工作,因为我需要从review.xhtml重新发布.我如何添加这个f:param标签,然后在bean中处理它?<​​/p>

ok I am trying to use the f:param here to pass the requestid as parameter to the review page. Currently am doing it as shown below but managedproperty is not working as I want because I need to post again from review.xhtml. How can i add this f:param tag and then handle it in bean?

    <p:dataTable style="width:50px;" id="requestList" value="#
            {requestBean.requestsList}" var="requestClass">  
            <p:column>  
                <f:facet name="header">  
                    <h:outputText value="ID" />  
                </f:facet> 
                 <a href="review.xhtml?id=#{requestClass.requestID}">
                    <h:outputText value="#{requestClass.requestID}" />  
                 </a>

            </p:column>  

            <p:column>  
                <f:facet name="header">  
                    <h:outputText value="Status" />  
                </f:facet>  
                <h:outputText value="#{requestClass.requestStatus}" />  
            </p:column>  

              <p:column>  
                <f:facet name="header">  
                    <h:outputText value="Details" />  
                </f:facet>  
                  <h:outputText value="#{requestClass.requestTitle}" />  
            </p:column>
        </p:dataTable>  

谢谢

推荐答案

我认为您可以尝试以下操作:

I think you can try the following:

.将您的bean保持为RequestScoped,并在review.xhtml中的表单中放置一个隐藏字段以包含ID:

. Keep your bean as RequestScoped and put a hidden field in your form in review.xhtml to contain the id:

<h:form>
   ...
   <h:inputHidden id="id" value="#{mrBean.id}" />
   ...
</h:form>

@ManagedBean(name = "mrBean")
@RequestScoped
public class MrBean {
   @ManagedProperty(value = "#{param.id}")
   private String id;
}

.将您的bean保持为RequestScoped,并在review.xhtml中的commandButton中放置一个<f:param>:

. Keep your bean as RequestScoped and put a <f:param> inside the commandButton in review.xhtml:

<h:form>
   ...
   <h:commandButton value="Submit">
      <f:param name="id" value="#{param.id)" />
   </h:commandButton>
</h:form>

.将您的bean更改为ViewScoped

. Change you bean to ViewScoped

@ManagedBean(name = "mrBean")
@ViewScoped
public class MrBean {
   private String id;

   @PostConstruct
   public void prepareReview() {
       HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
       id = request.getParameter("id");
   }
}

这篇关于JSF添加&lt; f:param&gt;到数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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