开发者

How can I correctly use <s:action name="populate" executeResult="true"/>?

开发者_如何学CI have this jsp

<s:form action="saveOrUpdateProduct" method="post" enctype="multipart/form-data" validate="true" theme="css_xhtml ">
    <s:textfield name="product.productName" label="Name" required="true" requiredposition="left" labelposition="left"></s:textfield>
    <br>
    <s:textfield name="product.productPrice" label="Price" required="true" requiredposition="left" value="1.0" labelposition="left"></s:textfield>
    <br>
    <s:hidden name="product.available" value="true"></s:hidden>
    <s:textarea name="product.productDescription" label="Description" required="true" requiredposition="left" labelposition="left"></s:textarea>
    <br>
    <s:action name="populate" executeResult="true"/>
    <s:file name="userImage" label="Picture" required="true" requiredposition="left" labelposition="left"/>
    <br>
    <s:submit value="Add"></s:submit>
    <br>
    </div>
</s:form>

If the file uploaded isn't a picture i would like to return to the same page with an error message, but when i try this, it shows the same page without executing <s:action name="populate"> that populates 2 <s:select>

I couldn't find an example that works. The example from Struts 2 documentation works for result name="success", but not for "input".


Why don't you make your action implement Preparable. In the prepare method, populate the selects, rather than having an <s:action>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜