You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carlos Saraiva <r1...@carlossaraiva.com> on 2003/06/08 19:23:04 UTC

How to access the ActionForm instance from within the JSP

Hi,

I need to call methods of the ActionForm instance from within the JSP. Can
someone please tell me how to do this? I've tried defining a bean, but I get
a different instance of the class.

--
Best regards,
Carlos Saraiva
Raleigh, NC
http://www.carlossaraiva.com mailto:saraiva@pobox.com



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


Re: How to access the ActionForm instance from within the JSP

Posted by Vic Cekvenich <vi...@baseBeans.com>.
If I can suggest that this is not MVC and not Struts.
Consider, if you have not yet, purchasing a Struts book.

And maybe post a JSP mail list, if you are not using Struts to 
pre-populate a bean in action.

.V


Carlos Saraiva wrote:

>>>Hi,
>>>
>>>I need to call methods of the ActionForm instance from within
>>>      
>>>
>>the JSP. Can
>>    
>>
>>>someone please tell me how to do this? I've tried defining a bean, but I
>>>      
>>>
>>get
>>    
>>
>>>a different instance of the class.
>>>      
>>>
>
>  
>
>>Which kind of methods do you need to call?
>>
>>Marco
>>    
>>
>
>Methods written by myself.
>
>--
>Best regards,
>Carlos Saraiva
>Raleigh, NC
>http://www.carlossaraiva.com mailto:saraiva@pobox.com
>  
>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
Open Source <a href ="baseBeans.com">Content Management</a>  basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress



RE: How to access the ActionForm instance from within the JSP

Posted by Carlos Saraiva <r1...@carlossaraiva.com>.
Thanks Marco, I think I know how to do that.

--
Best regards,
Carlos Saraiva
Raleigh, NC
http://www.carlossaraiva.com mailto:saraiva@pobox.com

> -----Original Message-----
> From: Marco Tedone [mailto:mtedone@jemos.org]
> Sent: Sunday, June 08, 2003 4:35 PM
> To: Struts Users Mailing List
> Subject: Re: How to access the ActionForm instance from within the JSP
>
>
> Put the form which contains the properties you want to reuse in a session
> scope, and then from the JSP use this form.
>
> Marco
> ----- Original Message -----
> From: "Carlos Saraiva" <r1...@carlossaraiva.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Sunday, June 08, 2003 9:27 PM
> Subject: RE: How to access the ActionForm instance from within the JSP
>
>
> > OK, here's the deal. I've got a JSP with a form that's included
> in another
> > JSP. When the imbedded JSP gets called, I want the fields in the form to
> be
> > populated by the attributes of the object it represents. The form object
> > doesn't get called before the JSP is instantiated. I'm looking for a way
> to
> > do this.
> >
> > --
> > Best regards,
> > Carlos Saraiva
> > Raleigh, NC
> > http://www.carlossaraiva.com mailto:saraiva@pobox.com
> >
> > > -----Original Message-----
> > > From: Marco Tedone [mailto:mtedone@jemos.org]
> > > Sent: Sunday, June 08, 2003 4:21 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: How to access the ActionForm instance from within the JSP
> > >
> > >
> > > Ok, which functionalities do those method perform? Have you thought to
> > > personal taglibs? The ActionForm should contain only getter/setter and
> > > validation methods. *Work* methods on data could be easily
> > > grouped somewhere
> > > else. The logic of the framework is request -> ?action(form) ->
> > > presentation, thus doing something like presentation-> form
> > > doesn't seem to
> > > me the right way to perform some logic in your application. IMHO, data
> > > should arrive to the JSP already formatted and ready to be
> > > displayed. What I
> > > see as normal, is to have scope attributes to manage from within your
> JSP;
> > > to avoid code you can write custom tags.
> > >
> > > Marco
> > > ----- Original Message -----
> > > From: "Carlos Saraiva" <r1...@carlossaraiva.com>
> > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > Sent: Sunday, June 08, 2003 9:13 PM
> > > Subject: RE: How to access the ActionForm instance from within the JSP
> > >
> > >
> > > > > > Hi,
> > > > > >
> > > > > > I need to call methods of the ActionForm instance from within
> > > > > the JSP. Can
> > > > > > someone please tell me how to do this? I've tried defining
> > > a bean, but
> > > I
> > > > > get
> > > > > > a different instance of the class.
> > > >
> > > > >
> > > > > Which kind of methods do you need to call?
> > > > >
> > > > > Marco
> > > >
> > > > Methods written by myself.
> > > >
> > > > --
> > > > Best regards,
> > > > Carlos Saraiva
> > > > Raleigh, NC
> > > > http://www.carlossaraiva.com mailto:saraiva@pobox.com
> > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > 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


Re: How to access the ActionForm instance from within the JSP

Posted by Marco Tedone <mt...@jemos.org>.
Put the form which contains the properties you want to reuse in a session
scope, and then from the JSP use this form.

Marco
----- Original Message ----- 
From: "Carlos Saraiva" <r1...@carlossaraiva.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, June 08, 2003 9:27 PM
Subject: RE: How to access the ActionForm instance from within the JSP


> OK, here's the deal. I've got a JSP with a form that's included in another
> JSP. When the imbedded JSP gets called, I want the fields in the form to
be
> populated by the attributes of the object it represents. The form object
> doesn't get called before the JSP is instantiated. I'm looking for a way
to
> do this.
>
> --
> Best regards,
> Carlos Saraiva
> Raleigh, NC
> http://www.carlossaraiva.com mailto:saraiva@pobox.com
>
> > -----Original Message-----
> > From: Marco Tedone [mailto:mtedone@jemos.org]
> > Sent: Sunday, June 08, 2003 4:21 PM
> > To: Struts Users Mailing List
> > Subject: Re: How to access the ActionForm instance from within the JSP
> >
> >
> > Ok, which functionalities do those method perform? Have you thought to
> > personal taglibs? The ActionForm should contain only getter/setter and
> > validation methods. *Work* methods on data could be easily
> > grouped somewhere
> > else. The logic of the framework is request -> ?action(form) ->
> > presentation, thus doing something like presentation-> form
> > doesn't seem to
> > me the right way to perform some logic in your application. IMHO, data
> > should arrive to the JSP already formatted and ready to be
> > displayed. What I
> > see as normal, is to have scope attributes to manage from within your
JSP;
> > to avoid code you can write custom tags.
> >
> > Marco
> > ----- Original Message -----
> > From: "Carlos Saraiva" <r1...@carlossaraiva.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Sunday, June 08, 2003 9:13 PM
> > Subject: RE: How to access the ActionForm instance from within the JSP
> >
> >
> > > > > Hi,
> > > > >
> > > > > I need to call methods of the ActionForm instance from within
> > > > the JSP. Can
> > > > > someone please tell me how to do this? I've tried defining
> > a bean, but
> > I
> > > > get
> > > > > a different instance of the class.
> > >
> > > >
> > > > Which kind of methods do you need to call?
> > > >
> > > > Marco
> > >
> > > Methods written by myself.
> > >
> > > --
> > > Best regards,
> > > Carlos Saraiva
> > > Raleigh, NC
> > > http://www.carlossaraiva.com mailto:saraiva@pobox.com
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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


RE: How to access the ActionForm instance from within the JSP

Posted by Carlos Saraiva <r1...@carlossaraiva.com>.
OK, here's the deal. I've got a JSP with a form that's included in another
JSP. When the imbedded JSP gets called, I want the fields in the form to be
populated by the attributes of the object it represents. The form object
doesn't get called before the JSP is instantiated. I'm looking for a way to
do this.

--
Best regards,
Carlos Saraiva
Raleigh, NC
http://www.carlossaraiva.com mailto:saraiva@pobox.com

> -----Original Message-----
> From: Marco Tedone [mailto:mtedone@jemos.org]
> Sent: Sunday, June 08, 2003 4:21 PM
> To: Struts Users Mailing List
> Subject: Re: How to access the ActionForm instance from within the JSP
>
>
> Ok, which functionalities do those method perform? Have you thought to
> personal taglibs? The ActionForm should contain only getter/setter and
> validation methods. *Work* methods on data could be easily
> grouped somewhere
> else. The logic of the framework is request -> ?action(form) ->
> presentation, thus doing something like presentation-> form
> doesn't seem to
> me the right way to perform some logic in your application. IMHO, data
> should arrive to the JSP already formatted and ready to be
> displayed. What I
> see as normal, is to have scope attributes to manage from within your JSP;
> to avoid code you can write custom tags.
>
> Marco
> ----- Original Message -----
> From: "Carlos Saraiva" <r1...@carlossaraiva.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Sunday, June 08, 2003 9:13 PM
> Subject: RE: How to access the ActionForm instance from within the JSP
>
>
> > > > Hi,
> > > >
> > > > I need to call methods of the ActionForm instance from within
> > > the JSP. Can
> > > > someone please tell me how to do this? I've tried defining
> a bean, but
> I
> > > get
> > > > a different instance of the class.
> >
> > >
> > > Which kind of methods do you need to call?
> > >
> > > Marco
> >
> > Methods written by myself.
> >
> > --
> > Best regards,
> > Carlos Saraiva
> > Raleigh, NC
> > http://www.carlossaraiva.com mailto:saraiva@pobox.com
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: How to access the ActionForm instance from within the JSP

Posted by Marco Tedone <mt...@jemos.org>.
Ok, which functionalities do those method perform? Have you thought to
personal taglibs? The ActionForm should contain only getter/setter and
validation methods. *Work* methods on data could be easily grouped somewhere
else. The logic of the framework is request -> ?action(form) ->
presentation, thus doing something like presentation-> form doesn't seem to
me the right way to perform some logic in your application. IMHO, data
should arrive to the JSP already formatted and ready to be displayed. What I
see as normal, is to have scope attributes to manage from within your JSP;
to avoid code you can write custom tags.

Marco
----- Original Message ----- 
From: "Carlos Saraiva" <r1...@carlossaraiva.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, June 08, 2003 9:13 PM
Subject: RE: How to access the ActionForm instance from within the JSP


> > > Hi,
> > >
> > > I need to call methods of the ActionForm instance from within
> > the JSP. Can
> > > someone please tell me how to do this? I've tried defining a bean, but
I
> > get
> > > a different instance of the class.
>
> >
> > Which kind of methods do you need to call?
> >
> > Marco
>
> Methods written by myself.
>
> --
> Best regards,
> Carlos Saraiva
> Raleigh, NC
> http://www.carlossaraiva.com mailto:saraiva@pobox.com
>
>
>
> ---------------------------------------------------------------------
> 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


RE: How to access the ActionForm instance from within the JSP

Posted by Carlos Saraiva <r1...@carlossaraiva.com>.
> > Hi,
> >
> > I need to call methods of the ActionForm instance from within
> the JSP. Can
> > someone please tell me how to do this? I've tried defining a bean, but I
> get
> > a different instance of the class.

>
> Which kind of methods do you need to call?
>
> Marco

Methods written by myself.

--
Best regards,
Carlos Saraiva
Raleigh, NC
http://www.carlossaraiva.com mailto:saraiva@pobox.com



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


Re: How to access the ActionForm instance from within the JSP

Posted by Marco Tedone <mt...@jemos.org>.
Which kind of methods do you need to call?

Marco
----- Original Message ----- 
From: "Carlos Saraiva" <r1...@carlossaraiva.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, June 08, 2003 6:23 PM
Subject: How to access the ActionForm instance from within the JSP


> Hi,
>
> I need to call methods of the ActionForm instance from within the JSP. Can
> someone please tell me how to do this? I've tried defining a bean, but I
get
> a different instance of the class.
>
> --
> Best regards,
> Carlos Saraiva
> Raleigh, NC
> http://www.carlossaraiva.com mailto:saraiva@pobox.com
>
>
>
> ---------------------------------------------------------------------
> 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