Stephane,
it's not exactly clear what you are trying to achieve or what the problem is (apart from ugly code).


Why do you have to fill the id field manually in the JSP via EL? It should be automatic from the form bean. Perhaps you haven't linked up the formbean and the action mapping in struts-config properly.

Also, what is the html:img 'select' dispatch? Does this somehow display the image on the page? It looks recursive / infinite loop-like.

Adam


On 04/18/2004 10:45 PM Stephane Bailliez wrote:
I'm fighting to find a clean solution to the following problem and hope that
the experts out there can provide

Context:

- File upload size limit set via the struts controller
- DynaValidatorForm with properties (id, dispatch, file)
- CRUD action create/read/update/delete via DispatchAction
   - create/update obviouslly use the form properties
   - read/delete only need a query parameter id
- object.jsp retrieve the current value (read) of the object and propose the
form to create/update the object
- validation xml set 'file'  to requiredwhen dispatch == select and dispatch
== create

object.jsp is something like this:

----------------- object.jsp --------------
<c:if test="${not empty param.id}">
  <c:set var="id" value="param.id" scope="page"/>
</c:if>
<c:if test="${not empty myform.map.id}">
  <c:set var="id" value="myform.map.id" scope="page"/>
</c:if>

<html:form action="object.do" enctype="multipart/form-data">
<html:img page="/object.do?dispatch=select&id=${id}"/>
<html:hidden property="id" value="${id}"/>
<html:hidden property="dispatch"/>
<html:file property="file" accept="image/jpeg"/>
<html:submit/>
</html:form>

Not that in case of create/update success, it is forwarded to this page
again.

I imagine it is not correct at all considering my zero experience with
Struts, but I'd be glad if someone could give me an idea of how to do
something cleaner than this absoltely ugly code. My problem is mostly to
deal with the fact that I need to retrieve the id both in the request and
the form, but I'm not satisfied with the above.

Thanks a lot for any help.





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to