简体   繁体   English

h:commandLink JSF文件下载

[英]h:commandLink JSF file download

I am trying to create a download link in a JSF page. 我正在尝试在JSF页面中创建下载链接。 The page has many richfaces fields that have validation enabled. 该页面包含许多已启用验证的richfaces字段。 Some have validator methods attached to them, some just have the required attribute set to true. 有些附加了验证器方法,有些只是将required属性设置为true。 The download link is an h:commandlink element. 下载链接是一个h:commandlink元素。 This link is supposed to download a file from the server. 此链接应该从服务器下载文件。 When I click on the link, validation on a few fields is triggered. 当我点击链接时,会触发几个字段的验证。 How can I avoid this? 我怎么能避免这个?

Thanks. 谢谢。

Either put it in a separate form, 要么把它放在一个单独的形式,

<h:form>
    ... other input fields ...
</h:form>
<h:form>
    <h:commandLink value="Download" action="#{bean.download}" />
</h:form>

or use immediate="true" so that all input fields which do not have this attribute set will be skipped in the process 或者使用immediate="true"以便在此过程中跳过所有没有设置此属性的输入字段

<h:commandLink value="Download" action="#{bean.download}" immediate="true" />

The issue was with the file on the server side. 问题出在服务器端的文件上。 Issue resolved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM