struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amleto Di Salle" <disa...@di.univaq.it>
Subject R: R: Turning OFF auto form population?
Date Wed, 19 May 2004 18:30:05 GMT
Hi, 
you are right when you said "...I'd like to avoid doing that...", but
unfortunely the only possible solution is to extend the RequestProcessor
and override the processPopulate() method.

Maybe the solution is to eliminate the RequestUtils.populate inside the
processPopulate() method, i.e
protected void processPopulate(HttpServletRequest request,
HttpServletResponse response, ActionForm form, ActionMapping mapping)
throws ServletException {

        if (form == null) {
            return;
        }

        // Populate the bean properties of this ActionForm instance
        if (log.isDebugEnabled()) {
            log.debug(" Populating bean properties from this request");
        }
        form.setServlet(this.servlet);
        form.reset(mapping, request);
        if (mapping.getMultipartClass() != null) {
            request.setAttribute(Globals.MULTIPART_KEY,
                                 mapping.getMultipartClass());
        }
/*
TO ELIMINATE!!!!
        RequestUtils.populate(form, mapping.getPrefix(),
mapping.getSuffix(),
                              request);
*/
        // Set the cancellation request attribute if appropriate
        if ((request.getParameter(Constants.CANCEL_PROPERTY) != null) ||
            (request.getParameter(Constants.CANCEL_PROPERTY_X) != null))
{
            request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
        }

}

The other thing to do is to configure the strut-config.xml, i.e.

<controller processorClass="com.pincopallo.RequestProcessorExtended"/>

BR
/Amleto

-----Messaggio originale-----
Da: None None [mailto:fzammett@hotmail.com] 
Inviato: mercoledì 19 maggio 2004 20.08
A: user@struts.apache.org
Oggetto: RE: R: Turning OFF auto form population?


That's interesting, I knew Struts was designed to be extended in a
number of 
places, I hadn't thought of doing that... However, I've purposely NOT 
extended it in some other places, and I'd like to avoid doing that, just

from a philosophical point of view (i.e., unless I have a real good
reason 
to, it's probably less complex to use the Struts classes as-is).  It's a

thought though.

You raise an interesting point about the name attribute though... I know
I 
can just leave it out, and then I'll be responsible for instantiating
the 
ActionForm and putting it in request to return to the view (which is
what 
our homegrown framework does).  I was thinking that I would let Struts 
instantiate it for me, and send it to the view for me, then I can remove

some code that would at that point be superfolous.  But, your point is a

good one: since the code is doing it already, I can just NOT specify an 
ActionForm for the Actions, then it wouldn't matter what class I extend
them 
from.  That would do the trick.

But, I still at some future point would have to go back into 
struts-config.xml and put the name attribute back in becuase presumably
I'm 
going to want to do that eventually (and I in fact do).  So, although
what 
you point out is a solution I can use, I'd still like to know if there
is a 
way I can get the benefit of Struts handling the creation of the
ActionForm 
and the passing it to the view for me WITHOUT having it auto-populate it
on 
the way in.  That's still i think the ideal situation for me, if it's 
possible, so the question still stands.


>From: "Amleto Di Salle" <disalle@di.univaq.it>
>Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
>To: "'Struts Users Mailing List'" <user@struts.apache.org>
>Subject: R: Turning OFF auto form population?
>Date: Wed, 19 May 2004 19:59:16 +0200
>
>Hi,
>but have you used in the action tag inside the "struts-config.xml" the 
>"name" attribute?
>
>Anyway, if I understood correctly, you can always extend the 
>RequestProcessor class and override the processPopulate(...) method.
>
>Furthermore, you have to configure struts to use the extended 
>RequestProcessor version.
>
>BR
>/Amleto
>
>
>-----Messaggio originale-----
>Da: None None [mailto:fzammett@hotmail.com]
>Inviato: mercoledì 19 maggio 2004 19.33
>A: user@struts.apache.org
>Oggetto: Turning OFF auto form population?
>
>
>Hello all... Is it possible to turn OFF Struts auto-populating an 
>ActionForm with the paramters from the client?
>
>The reason I ask is that I'm converting a non-Struts app over, and in 
>this app, because it was using a homegrown framework, we have value 
>object classes which are basically exactly what ActionForms are, except

>that they
>are NOT auto-popualated.  The problem is that some of the getter and
>setter
>method names may not match the input parameters, and rather than trying
>to
>go through it all and change the names to match (which I can do as a
>later
>step), I'd like to turn off the auto-populate function if I can.
>
>If I can't, I can just leave these classes as-is and just have them not

>extend ActionForm... since they are always manually dealt with, that's 
>not a problem, but if I can make make them extend ActionForm and turn 
>off the auto-populate, then I can just swing back around in a later 
>iteration and
>make the changes I need to then.
>
>Thanks all!
>
>_________________________________________________________________
>FREE pop-up blocking with the new MSN Toolbar – get it now! 
>http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
>---------------------------------------------------------------------
>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
>

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


---------------------------------------------------------------------
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