Ser*_*hyk 9 file-upload spring-webflow primefaces jsf-2
当我创建模型时,我想保存模型的图像.我正在使用PrimeFaces fileUpload组件.当我保存图片时,我想知道特定图像所指的模型.这就是我需要将模型的id发送到支持bean的原因.
有没有可能将模型的id发送到fileUploadListener?
<h:form enctype="multipart/form-data">
<p:panelGrid columns="2">
<h:outputLabel for="hotelName" value="#{msg.hotelName}"/>
<p:inputText value="#{apartmentNew.name}" id="hotelName"/>
<h:outputLabel for="hotelDescription" value="#{msg.hotelDescription}"/>
<p:inputText value="#{apartmentNew.description}" id="hotelDescription"/>
<h:outputLabel for="hotelImages" value="#{msg.hotelImages}"/>
<h:form enctype="multipart/form-data">
<p:fileUpload id="hotelImages"
fileUploadListener="#{apartments.handleImageUpload}"
mode="advanced"
sizeLimit="10000000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/">
</p:fileUpload>
</h:form>
</p:panelGrid>
<p:commandButton id="saveApartmentButton" value="#{msg.save}" action="save"/>
<p:commandButton id="cancelCreationApartmentButton" value="#{msg.cancel}"
action="cancel"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
Bal*_*usC 34
不是通过请求参数.您可以通过组件属性执行此操作.
例如
<p:fileUpload ...>
<f:attribute name="foo" value="bar" />
</p:fileUpload>
Run Code Online (Sandbox Code Playgroud)
同
String foo = (String) event.getComponent().getAttributes().get("foo"); // bar
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13338 次 |
| 最近记录: |