(don't mind me -- I'm a newbie)
Are Struts FormBeans stored in the session under a known key? If they
are, you could perhaps do the the following:
Use a scriptlet on top of your .jsp that recovers the formBean from
session scope and invokes your initValues(), like so:
myPage.jsp:
<%
MyFormBean formBeam = pageContext.getAttribute( "MyFormBean",
PageContext.SESSION_SCOPE );
formBean.initValues();
%>
<!-- struts tags here -->
This way, your initialization code gets executed and you don't have
to change the references to myPage.jsp . It's an ugly piece of code,
but...
[]'s
----- Original Message -----
From: <Nerijus.Navickas@srb-intl.com>
To: <struts-user@jakarta.apache.org>
Sent: Wednesday, April 16, 2003 12:54 PM
Subject: RE: about defaults
> Thanks for advice, but using DispatchAction or LookupDispatchAction
encountered
> that all action methods are executed AFTER from submission. That means I
can't
> directly access myPage.jsp, i must refer to myPage.do. And this is not a
big
> concern when you build new application, but when trying to rewrite a part
of
> existing application, i can't go all code and instead 'myPage.jsp' change
to 'myPage.do'.
> Even if i'll do it will involve forwards, includes etc. And this occurs
because
> struts does not have resetting to default values mechanism... :(
>
> I hate imagining myself going to boss and telling:
> 'with creap we have developed stuts framework seems involve too much
changes in existing code'...
>
> ~nn
>
>
> -----Original Message-----
> From: David Chelimsky [mailto:david@chelimsky.org]
> Sent: Wednesday, April 16, 2003 10:35 AM
> To: Struts Users Mailing List
> Subject: Re: about defaults
>
>
> Concerns understood. How about just looking at the BaseForm.java file
> rolling your own version. The concept sounds like what you're looking
> for - an easy way to initialize values w/o needing a second Action
> class. You could also use a DispatchAction (or LookupDispatchAction) and
> figure out whether the form is being submitted or initialized and handle
> accordingly. This, too, would keep everything in one Action.
>
> Nerijus.Navickas@srb-intl.com wrote:
>
> >Yup, but this comes with scaffold package. That means going to
> >manager delivering bunch of papers including licensing, terms,
> >conditions. That means long sitting in 2 or 5 Canadian meetings each
> >3 hours and waiting for final decision - do we need
> >org.apache.struts.scaffold package?
> >
> > - For what?
> > - For easy setting of initial values in form.
> >
> >Somehow sounds funny and strange...
> >
> >ps. right now in right post...
> >
> >-----Original Message-----
> >From: David Chelimsky [mailto:david@chelimsky.org]
> >Sent: Wednesday, April 16, 2003 10:00 AM
> >To: Struts Users Mailing List
> >Subject: Re: about defaults
> >
> >
> >Take a look at item 5.7.3 (page 181) in "Struts in Action". This may be
> >what you're looking for.
> >
> >Nerijus.Navickas@srb-intl.com wrote:
> >
> >
> >
> >>No, before that it was explained to me (in this group) that there is
> >>'general default' which means all checkboxes off because checkboxes in
off stage
> >>are not submitted.
> >>
> >>So as it was explained 'general default' is not the same as 'user
default'. For example: i have a form
> >>of 3 checkboxes and want initially 2 boxes to be checked on. Problem is
that in ActionForm.reset()
> >>i should set all values to 'general default' and to set values to 'user
default' i need to
> >>have action 'initForm' So for one form I should have 2 action classes:
init and forward.
> >>That looks ugly to me. I dunno know much about stuts but seems it
becomes a problem to have default values.
> >>I have bought 'Struts in action' listed all night, and no one word about
initial form setup.
> >>Simple thing comes impossible. Would it kill struts to have method
'initValues()'?
> >>
> >>
> >>~NN
> >>
> >>-----Original Message-----
> >>From: James Mitchell [mailto:jmitchell@apache.org]
> >>Sent: Wednesday, April 16, 2003 5:15 AM
> >>To: Struts Users Mailing List
> >>Subject: Re: about defaults
> >>
> >>
> >>On Wednesday 16 April 2003 11:34 am, Nerijus.Navickas@srb-intl.com
wrote:
> >>
> >>
> >>
> >>
> >>>Sorry for not being clear,
> >>>
> >>>ActionForm. As reset() is called for resetting values to 'general
default'
> >>>there is no method for setting for 'user default'. Should I implement
some
> >>>boolean flag which means 'reset was called first time for this form' or
> >>>should I go different way?
> >>>
> >>>
> >>>
> >>>
> >>I guess I don't know what you mean by 'user default'. Are you meaning
that
> >>you have different default values for different users?
> >>
> >>
> >>
> >>
> >>
> >>>~nn
> >>>
> >>>
> >>>
> >>>-----Original Message-----
> >>>From: James Mitchell [mailto:jmitchell@apache.org]
> >>>Sent: Tuesday, April 15, 2003 11:35 AM
> >>>To: Struts Users Mailing List
> >>>Subject: Re: about defaults
> >>>
> >>>On Tuesday 15 April 2003 07:08 pm, Nerijus.Navickas@srb-intl.com wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Hi,
> >>>>
> >>>>can anyone in normal way tell how to set user default values,
please...
> >>>>
> >>>>
> >>>>
> >>>>
> >>>What are we talking about here? ActionForm? DynaActionForm? What?
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>~nn
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>
> >>
> >>
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
|