Hi,
        I might be wrong, but if u do a direct access  such
http://xxxx/action.do?dispatch=method&id=1234

What will happen is that the form is populated, then passed
DispatchAction (which will do eventually some logic on it), then the
form is reset and then it is sent to the page.
If I m correct, all form properties are reset between one request and
the other.
So, you either make ur bean with sessionscope or you hardcode the id
Population in the method()  method  of your DispatchAction

Hope this helps
Regards
        marco

.


-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Stephane Bailliez
Sent: 19 April 2004 14:28
To: [EMAIL PROTECTED]
Subject: Re: DispatchAction / DynaValidatorForm / Upload best practice


"Adam Hardy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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: [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]


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

Reply via email to