struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Mistroni" <mmistr...@waersystems.com>
Subject RE: DispatchAction / DynaValidatorForm / Upload best practice
Date Tue, 20 Apr 2004 10:38:00 GMT
Hi,
	Yes I was not meaning because of dispatchaction..
I guess this happens with Action in general, due to the reason
That you mentioned...
Actually I have read (from struts in action I believe) that bean
Properties are reset between 'requests'
So URL -> dispatch -> JSP are actually two 'requests'.. you won't find
at stage 3 the same properties that u find on stage 1, unless ur form
has
session scope..

regards
	marco

-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
Sent: 19 April 2004 18:57
To: Struts Users Mailing List
Subject: Re: DispatchAction / DynaValidatorForm / Upload best practice

I've just realised that Marco may be partially correct - but it's not 
due to the dispatch action, it's due to the multipart request formbean. 
Perhaps if you look in the archives for multi-part request, you'll find 
some interesting stuff. I'm not sure at this point myself.

Adam

On 04/19/2004 03:28 PM Stephane Bailliez wrote:
> "Adam Hardy" <ahardy.struts@cyberspaceroad.com> wrote in message
> news:4083AD44.2040801@cyberspaceroad.com...
> 
>>Stephane,
>>it's not exactly clear what you are trying to achieve or what the
>>problem is (apart from ugly code).
> 
> 
> The problem is the 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.
> 
> 
> That's the problem. It is not automatic from the form bean. And I
would like
> to know why it does not do the mapping (and if it can w/o some ugly
black
> magic)
> 
> I'm accessing the page from different entry points with query
parameters (or
> from post) and for some reasons, it does not map the query parameter
to the
> form when it is a direct access such http://xxxx/action.do
> ?dispatch=method&id=1234. When it is posted, it is of course ok. My
problem
> is just 'direct access'
> 
> The struts-config.xml  is something like this:
> 
>         <form-bean name="myform"
> type="org.apache.struts.validator.DynaValidatorForm">
>             <form-property name="dispatch" type="java.lang.String"/>
>             <form-property name="file"
> type="org.apache.struts.upload.FormFile"/>
>             <form-property name="id" type="java.lang.String"/>
>         </form-bean>
> 
>        <action path="/myaction" type="samples.MyAction"
>             name="myform" scope="request" validate="true"
>             parameter="dispatch" input="edit">
>             <forward name="updateSuccess" path="/jsp/mypage.jsp"/>
>             <forward name="createSuccess" path="/jsp/mypage.jsp"/>
>             <forward name="edit" path="/jsp/mypage.jsp"/>
>             <!-- forward to the binary servlet path to serve images,
see
> web.xml -->
>             <forward name="selectSuccess" path="/binary"/>
>         </action>
> 
>>Also, what is the html:img 'select' dispatch? Does this somehow
display
>>the image on the page? It looks recursive / infinite loop-like.
> 
> 
> No, it's like a preview, or edition of an object. It just get the
current
> value of the object.
> 
> 
> 
>>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: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>>-- 
>>struts 1.2 + tomcat 5.0.19 + java 1.4.2
>>Linux 2.4.20 Debian
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message