You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dirk Markert <di...@dr-markert.de> on 2003/07/16 16:12:01 UTC

Re[6]: Question about the form tag

Hello Nadja,

    my test looks like:

<html:form action="change" >
 <html:text property="name" />
 <html:submit property="f1" >Senden 1</html:submit>
</html:form>

<html:form action="change" >
 <html:text property="name" />
 <html:submit property="f2" >Senden 1</html:submit>
</html:form>

Hitting button 1 gives me the text from the first and hitting button 2
gives me the text from the second form. Whats the difference to your
jsp?

***************************************************************

NS> Hello,

>>     I just made a small test with multiple forms on one page. I only
>>     get the params of the form to which the submit action belongs!?

NS> Yes, but I have the same submit action for every form, meaning they all
NS> have this form tag:

NS> <html:form action="/geraetaendern">

NS> That's why I am having problems.

NS> Greetings,
NS> Nadja

NS> ---------------------------------------------------------------------
NS> Nadja  Senoucci
NS> Universitaet Hamburg
NS> Zentrum für Molekulare Neurobiologie
NS> Service-Gruppe EDV
NS> Falkenried 94
NS> 20251 Hamburg
NS> Germany
NS> Tel.:040 - 428 - 03 - 6619
NS> Fax.:040 - 428 - 03 - 6621


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



Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+ 


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


Re: Re[10]: Question about the form tag

Posted by Nadja Senoucci <Na...@zmnh.uni-hamburg.de>.
Hello Dirk,

>I set up a test jsp like above and I get values from form 2, if I
>click any button of form 2 (and vice versa). I guess either your
>struts-config or your action form is not correct.

Hmm... I guess, I will have to look into this some more tomorrow then. This
is really odd, because the form works fine if I only display one form and I
have logging information that tells me I do get the ID of the first object
even though in my second form the hidden field is correctly filled with the
ID of the second object... I assume, this will bug me for a while... <sighs>

Thanks for all your help.

Greetings,
Nadja

---------------------------------------------------------------------
Nadja  Senoucci
Universitaet Hamburg
Zentrum für Molekulare Neurobiologie
Service-Gruppe EDV
Falkenried 94
20251 Hamburg
Germany
Tel.:040 - 428 - 03 - 6619
Fax.:040 - 428 - 03 - 6621


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


Re[10]: Question about the form tag

Posted by Dirk Markert <di...@dr-markert.de>.
Hello Nadja,

  

***************************************************************

NS> Hello Dirk,

>> something like:
>>
>><html:form action="change" >
>> <html:text property="name" />
>> <html:submit property="f1a" >Senden A</html:submit>
>> <html:submit property="f1b" >Senden B</html:submit>
>> <html:submit property="f1c" >Senden C</html:submit>
>></html:form>
>>
>><html:form action="change" >
>> <html:text property="name" />
>> <html:submit property="f2a" >Senden A</html:submit>
>> <html:submit property="f2b" >Senden B</html:submit>
>> <html:submit property="f2c" >Senden C</html:submit>
>></html:form> 

NS> But then I would still have to be looking for "f2a" in the request, won't
NS> I? And that I could do that would mean that I'd know already which form
NS> should've been submitted and/or which forms or how many existed on page at
NS> all.

NS> This is what my forms look like at the moment (just with more and different
NS> data for each object...):

NS> <html:form action="change" >
NS>  <html:text property="name" />
NS>  <html:submit property="fa" >Senden A</html:submit>
NS>  <html:submit property="fb" >Senden B</html:submit>
NS>  <html:submit property="fc" >Senden C</html:submit>
NS> </html:form>

NS> <html:form action="change" >
NS>  <html:text property="name" />
NS>  <html:submit property="fa" >Senden A</html:submit>
NS>  <html:submit property="fb" >Senden B</html:submit>
NS>  <html:submit property="fc" >Senden C</html:submit>
NS> </html:form>

I set up a test jsp like above and I get values from form 2, if I
click any button of form 2 (and vice versa). I guess either your
struts-config or your action form is not correct.


NS> That allows me to look for "fa" in the request to find out whether it has
NS> been set/pressed or not.

NS> Greetings,
NS> Nadja

NS> ---------------------------------------------------------------------
NS> Nadja  Senoucci
NS> Universitaet Hamburg
NS> Zentrum für Molekulare Neurobiologie
NS> Service-Gruppe EDV
NS> Falkenried 94
NS> 20251 Hamburg
NS> Germany
NS> Tel.:040 - 428 - 03 - 6619
NS> Fax.:040 - 428 - 03 - 6621


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



Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+ 


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


Re: Re[8]: Question about the form tag

Posted by Nadja Senoucci <Na...@zmnh.uni-hamburg.de>.
Hello Dirk,

> something like:
>
><html:form action="change" >
> <html:text property="name" />
> <html:submit property="f1a" >Senden A</html:submit>
> <html:submit property="f1b" >Senden B</html:submit>
> <html:submit property="f1c" >Senden C</html:submit>
></html:form>
>
><html:form action="change" >
> <html:text property="name" />
> <html:submit property="f2a" >Senden A</html:submit>
> <html:submit property="f2b" >Senden B</html:submit>
> <html:submit property="f2c" >Senden C</html:submit>
></html:form> 

But then I would still have to be looking for "f2a" in the request, won't
I? And that I could do that would mean that I'd know already which form
should've been submitted and/or which forms or how many existed on page at
all.

This is what my forms look like at the moment (just with more and different
data for each object...):

<html:form action="change" >
 <html:text property="name" />
 <html:submit property="fa" >Senden A</html:submit>
 <html:submit property="fb" >Senden B</html:submit>
 <html:submit property="fc" >Senden C</html:submit>
</html:form>

<html:form action="change" >
 <html:text property="name" />
 <html:submit property="fa" >Senden A</html:submit>
 <html:submit property="fb" >Senden B</html:submit>
 <html:submit property="fc" >Senden C</html:submit>
</html:form>

That allows me to look for "fa" in the request to find out whether it has
been set/pressed or not.

Greetings,
Nadja

---------------------------------------------------------------------
Nadja  Senoucci
Universitaet Hamburg
Zentrum für Molekulare Neurobiologie
Service-Gruppe EDV
Falkenried 94
20251 Hamburg
Germany
Tel.:040 - 428 - 03 - 6619
Fax.:040 - 428 - 03 - 6621


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


Re[8]: Question about the form tag

Posted by Dirk Markert <di...@dr-markert.de>.
Hello Nadja,

 something like:

<html:form action="change" >
 <html:text property="name" />
 <html:submit property="f1a" >Senden A</html:submit>
 <html:submit property="f1b" >Senden B</html:submit>
 <html:submit property="f1c" >Senden C</html:submit>
</html:form>

<html:form action="change" >
 <html:text property="name" />
 <html:submit property="f2a" >Senden A</html:submit>
 <html:submit property="f2b" >Senden B</html:submit>
 <html:submit property="f2c" >Senden C</html:submit>
</html:form> 

***************************************************************

NS> Hello,

>>    my test looks like:
>>
>><html:form action="change" >
>> <html:text property="name" />
>> <html:submit property="f1" >Senden 1</html:submit>
>></html:form>
>>
>><html:form action="change" >
>> <html:text property="name" />
>> <html:submit property="f2" >Senden 1</html:submit>
>></html:form>
>>
>>Hitting button 1 gives me the text from the first and hitting button 2
>>gives me the text from the second form. Whats the difference to your
>>jsp?

NS> My difference is with the buttons. They also have the same name. I have 4
NS> different submit buttons (actually 5 but only three get displayed at one
NS> time) for every object and two more for the whole form. They have each
NS> different names but the names do not change for different objects. And
NS> since my action looks like this:

NS> if(request.getParameter("aendern")!=null){
NS>         //do change stuff
NS> }else if(request.getParameter("deinventarisieren")!=null){
NS>         //deactivate object
NS> }else if(request.getParameter("reinventarisieren")!=null){
NS>         //reactivate object
NS> }else if(request.getParameter("print_geraet")!=null ||
NS> request.getParameter("print_archiv")!=null){
NS>         //print an object (two different print views)
NS> }else if(request.getParameter("print_multiple_geraete")!=null ||
NS> request.getParameter("print_multiple_archive")!=null){
NS>         //print multiple objects (two different print views)
NS> }

NS> I cannot really change the button names for each object, else I'd never
NS> what to look for in the request...

NS> Or am I doing things too complicated here?

NS> Greetings,
NS> Nadja

NS> ---------------------------------------------------------------------
NS> Nadja  Senoucci
NS> Universitaet Hamburg
NS> Zentrum für Molekulare Neurobiologie
NS> Service-Gruppe EDV
NS> Falkenried 94
NS> 20251 Hamburg
NS> Germany
NS> Tel.:040 - 428 - 03 - 6619
NS> Fax.:040 - 428 - 03 - 6621


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



Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+ 


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


RE: is Struts action class a Design Pattern of utility class?

Posted by Andrew Hill <an...@gridnode.com>.
You shouldnt be using (modifiable) instance methods in an Action class as
actions need to be threadsafe - remember that could be any number of threads
executing that code at the same time! (This is where request attributes come
in handy) so certainly you should be eliminating instance variables and
either declaring them as local and passing between your methods or shoving
them in a bean you pass between your methods or putting them in request
attributes...

As for making your methods static... you probably dont want to do that - you
will be choking off your ability to subclass your action amoung other
things. Take a look in the archive at the discussion last week about
singletons vs statics.

Actions are a helper class not a utility class. They are invoked by the
RequestProcessor to assist it in processing the use case specific logic of
the action.

-----Original Message-----
From: Denis Wang [mailto:dwang@brandmuscle.com]
Sent: Wednesday, 16 July 2003 22:29
To: Struts Users Mailing List
Subject: is Struts action class a Design Pattern of utility class?


Hello, all,
I am not sure whether it is a good practice to:
eliminate instance variables from Struts action class; and
make all methods static.
Basically it turns the action class into a utility class.
Any comments?  Thanks.
Denis


---------------------------------------------------------------------
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: is Struts action class a Design Pattern of utility class?

Posted by Sandeep Takhar <sa...@yahoo.com>.
You can still have static methods on the action, just
no instance variables that you update.  No instance
variables on actions is generally the case.

sandeep
--- David Graham <gr...@yahoo.com> wrote:
> --- Denis Wang <dw...@brandmuscle.com> wrote:
> > Hello, all,
> > I am not sure whether it is a good practice to:
> > eliminate instance variables from Struts action
> class; and
> > make all methods static.
> > Basically it turns the action class into a utility
> class.
> > Any comments?  Thanks.
> 
> Do *not* make your methods static.  Actions are
> Singletons and many
> threads may be running through them at one time so
> they must be thread
> safe.  This typically means you can't use instance
> variables to maintain
> state.  If you're interested in creating a new
> instance of each Action per
> request (thereby allowing you to use instance
> variables) you should look
> at overriding the
> RequestProcessor.processActionCreate() method.
> 
> David
> 
> 
> 
> > Denis
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Re: is Struts action class a Design Pattern of utility class?

Posted by David Graham <gr...@yahoo.com>.
--- Denis Wang <dw...@brandmuscle.com> wrote:
> Hello, all,
> I am not sure whether it is a good practice to:
> eliminate instance variables from Struts action class; and
> make all methods static.
> Basically it turns the action class into a utility class.
> Any comments?  Thanks.

Do *not* make your methods static.  Actions are Singletons and many
threads may be running through them at one time so they must be thread
safe.  This typically means you can't use instance variables to maintain
state.  If you're interested in creating a new instance of each Action per
request (thereby allowing you to use instance variables) you should look
at overriding the RequestProcessor.processActionCreate() method.

David



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


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


is Struts action class a Design Pattern of utility class?

Posted by Denis Wang <dw...@brandmuscle.com>.
Hello, all,
I am not sure whether it is a good practice to:
eliminate instance variables from Struts action class; and
make all methods static.
Basically it turns the action class into a utility class.
Any comments?  Thanks.
Denis


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


Re: Re[6]: Question about the form tag

Posted by Nadja Senoucci <Na...@zmnh.uni-hamburg.de>.
Hello,

>    my test looks like:
>
><html:form action="change" >
> <html:text property="name" />
> <html:submit property="f1" >Senden 1</html:submit>
></html:form>
>
><html:form action="change" >
> <html:text property="name" />
> <html:submit property="f2" >Senden 1</html:submit>
></html:form>
>
>Hitting button 1 gives me the text from the first and hitting button 2
>gives me the text from the second form. Whats the difference to your
>jsp?

My difference is with the buttons. They also have the same name. I have 4
different submit buttons (actually 5 but only three get displayed at one
time) for every object and two more for the whole form. They have each
different names but the names do not change for different objects. And
since my action looks like this:

if(request.getParameter("aendern")!=null){
	//do change stuff
}else if(request.getParameter("deinventarisieren")!=null){
	//deactivate object
}else if(request.getParameter("reinventarisieren")!=null){
	//reactivate object
}else if(request.getParameter("print_geraet")!=null ||
request.getParameter("print_archiv")!=null){
	//print an object (two different print views)
}else if(request.getParameter("print_multiple_geraete")!=null ||
request.getParameter("print_multiple_archive")!=null){
	//print multiple objects (two different print views)
}

I cannot really change the button names for each object, else I'd never
what to look for in the request...

Or am I doing things too complicated here?

Greetings,
Nadja

---------------------------------------------------------------------
Nadja  Senoucci
Universitaet Hamburg
Zentrum für Molekulare Neurobiologie
Service-Gruppe EDV
Falkenried 94
20251 Hamburg
Germany
Tel.:040 - 428 - 03 - 6619
Fax.:040 - 428 - 03 - 6621


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