加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

jsf – p:commandButton与p:fileDownload并且没有ajax只能在第

发布时间:2020-12-16 02:47:09 所属栏目:百科 来源:网络整理
导读:我正在使用JSF 2.0,Primefaces 3.4.2,Spring 3.1.2. 我正面临着这个链接的类似问题:h:commandButton works from the second click. 和他一样,我没有在 p:commandButton中使用ajax.但我正在使用 p:fileDownload /在按钮标签内. 我有两个视图:“list.xhtml
我正在使用JSF 2.0,Primefaces 3.4.2,Spring 3.1.2.

我正面临着这个链接的类似问题:h:commandButton works from the second click.

和他一样,我没有在< p:commandButton>中使用ajax.但我正在使用< p:fileDownload />在按钮标签内.

我有两个视图:“list.xhtml”和“downloadView.xhtml”.在myBean.java中,我从视图“list.xhtml”发送一个DataModel,以查看“downloadView.xhtml”作为请求属性,如下面的代码所示:

FacesUtil.getServletContext().setAttribute("myDataModelFromRequest",this.myDataModel);

该bean使用@Scope(“view”)进行了分配

在视图“downloadView.xhtml”中,我成功地使用从请求发送的DataModel填充了dataTable.但是,当我单击按钮下载文件时,问题就出现了.它只适用于第二次尝试.
我已经尝试将我的方法的返回值从null更改为“downloadView”,但问题没有解决.

在调试模式下,我注意到只在第二次点击时输入“downloadMethod()”.

有人有想法解决它吗?

myBean.java

public String viewListMethod() {
    //some work here...

    FacesUtil.getServletContext().setAttribute("myDataModelFromRequest",this.myDataModel);

    return "downloadView";
}

downloadView.xhtml

<h:form id="formId" prependId="false">
    <p:dataTable
        id="dataTableId" var="myVar" value="#{myDataModelFromRequest}"                  
        selection="#{cargaProcessoControlador.myArray}" 
        paginator="true" rows="10" paginatorPosition="bottom" paginatorAlwaysVisible="false">
            <f:facet name="header">  
                    bla bla bla
            </f:facet>

            <p:column selectionMode="multiple" style="width:18px" />

            //collumns here...                      
    </p:dataTable>


    <p:commandButton id="btDownload" ajax="false" value="Download" icon="ui-icon-document" >
        <p:fileDownload value="#{myBean.downloadMethod()}" />
    </p:commandButton>
</h:form>

解决方法

春天的范围“观点”不存在……所以你创造了自己的,对吧?只是为了检查…… 我曾经遇到过这样的问题,我认为这与验证有关… immediate = true属性解决了我的问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读