Re: HTML:Image (was: HTML / Struts Help)

2002-02-15 Thread Ted Husted

The advice in the User Guide may be obsolete now that we support the
dotted syntax :o(

You may need to define a ImageButtonBean on the ActionForm with x and y
properties. The getCreateButton method could then call the getX() (or
getY()) method on that bean to determine whether it was pushed. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


Mark Takacs wrote:
> 
> > You can use the  tag and set the property
> > to a value. Then in the action, you are able to find out,
> > which button was presed
> 
> Ok, this sounds fine, cept Im running into the .x .y problem outlined
> in the HTML:IMAGE docs.   Has anyone gotten this working with the
> html:image tag?  None of the dozen or so responses so far seem to
> address that point.
> 
> The html:image docs have this to say:
> 
> http://jakarta.apache.org/struts/struts-html.html
> 
> > 
> > The property name of this image tag. The parameter names
> > for the request will appear as "property.x" and "property.y",
> > the x and y representing the coordinates of the mouse click
> > for the image. A way of retrieving these values through a form
> > bean is to define getX(), getY(), setX(), and setY() methods,
> > and specify your propery as a blank string (property="").
> 
> ARG!  What if I *need* to use a named property to tell two images
> apart??
> 
> If I use
> 
> 
> 
> 
> They do indeed show up as "createButton.x=6" and "createButton.y=10",
> when I dump the request.  However, my  setCreateButton() never gets
> called.  I assume there's a "createButton.x" being tossed in the way.
> Mmking a methods called setCreateButtonX() didnt seem to help
> 
> Following the suggestion in the docs
> 
> 
> 
> 
> I can then create "setX()" and "setY()" which do get called.  However,
> I can no longer tell which button they pushed.. the create or the
> delete button.  My webdesign folks will *never* let me use a generic
> html submit button, it's GOT to be an image.
> 
> Here's what I'd like, following the suggestions so far.
> 
> page.jsp
>   
>   
> 
> bean.jsp
>   boolean createButton;
>   public void setCreateButton__???___(String createButtonParm) {
>createButton = true;
>   }
>   public boolean isCreateButton() {
>return createButton;
>   }
> 
> action.java
>   if (formBean.isCreateButton())
> 
> 
> I would really like to use the Form get/set method outlined above,
> instead of scrolling thru the entire Request object looking for
> parameters that start with "createButton.x".   It seems like I just
> need to figure out how to name the setter/getter methods in my bean so
> that the  tag actually calls the right part of the bean.
> 
> Currently Im looking thru the html:image taglib code...  urgh.
> 
> -tak
> 
> __
> Do You Yahoo!?
> Got something to say? Say it better with Yahoo! Video Mail
> http://mail.yahoo.com
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: HTML:Image (was: HTML / Struts Help)

2002-02-15 Thread Keith

A quick reply & probably crazy. But struts would try to call 
   formBean.getCreateButton().setX();

(It would I assume not try to call  formBean.getCreatebutton().getX()).

it might be worth trying in your form bean:-

public class formBean extends ActionForm {
   CreateButton createButton = new CreateButton();

   public CreateButton getCreateButton() {
  return CreateButton
   }
   //
   // I never know if you have to define a matching get/set pair
   // even if one of them has no use.
   //
   public CreateButton setCreateButton(ccc) {
  createButton = ccc;
   }


}
/*
* you'd probably have to make this public in it's own file!
*/

class CreateButton {
private int x = 0;
public void setX(int x) {this.x=x;}
public int getX() {return x;}
}




--- Mark Takacs <[EMAIL PROTECTED]> wrote:
> > You can use the  tag and set the property 
> > to a value. Then in the action, you are able to find out, 
> > which button was presed 
> 
> Ok, this sounds fine, cept Im running into the .x .y problem outlined
> in the HTML:IMAGE docs.   Has anyone gotten this working with the
> html:image tag?  None of the dozen or so responses so far seem to
> address that point.
> 
> The html:image docs have this to say:
> 
> http://jakarta.apache.org/struts/struts-html.html
> 
> > 
> > The property name of this image tag. The parameter names 
> > for the request will appear as "property.x" and "property.y", 
> > the x and y representing the coordinates of the mouse click 
> > for the image. A way of retrieving these values through a form 
> > bean is to define getX(), getY(), setX(), and setY() methods,
> > and specify your propery as a blank string (property="").
> 
> ARG!  What if I *need* to use a named property to tell two images
> apart??
> 
> If I use
> 
> 
> 
> 
> They do indeed show up as "createButton.x=6" and "createButton.y=10",
> when I dump the request.  However, my  setCreateButton() never gets
> called.  I assume there's a "createButton.x" being tossed in the way. 
> Mmking a methods called setCreateButtonX() didnt seem to help
> 
> Following the suggestion in the docs
> 
> 
> 
> 
> I can then create "setX()" and "setY()" which do get called.  However,
> I can no longer tell which button they pushed.. the create or the
> delete button.  My webdesign folks will *never* let me use a generic
> html submit button, it's GOT to be an image.  
> 
> Here's what I'd like, following the suggestions so far.
> 
> page.jsp
>   
>   
> 
> bean.jsp
>   boolean createButton;
>   public void setCreateButton__???___(String createButtonParm) {
>createButton = true;
>   }
>   public boolean isCreateButton() {
>return createButton;
>   }
> 
> action.java
>   if (formBean.isCreateButton()) 
>  
> 
> I would really like to use the Form get/set method outlined above,
> instead of scrolling thru the entire Request object looking for
> parameters that start with "createButton.x".   It seems like I just
> need to figure out how to name the setter/getter methods in my bean so
> that the  tag actually calls the right part of the bean.
> 
> Currently Im looking thru the html:image taglib code...  urgh.
> 
> -tak
> 
> 
> __
> Do You Yahoo!?
> Got something to say? Say it better with Yahoo! Video Mail 
> http://mail.yahoo.com
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 


__
Do You Yahoo!?
Got something to say? Say it better with Yahoo! Video Mail 
http://mail.yahoo.com

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




HTML:Image (was: HTML / Struts Help)

2002-02-14 Thread Mark Takacs

> You can use the  tag and set the property 
> to a value. Then in the action, you are able to find out, 
> which button was presed 

Ok, this sounds fine, cept Im running into the .x .y problem outlined
in the HTML:IMAGE docs.   Has anyone gotten this working with the
html:image tag?  None of the dozen or so responses so far seem to
address that point.

The html:image docs have this to say:

http://jakarta.apache.org/struts/struts-html.html

> 
> The property name of this image tag. The parameter names 
> for the request will appear as "property.x" and "property.y", 
> the x and y representing the coordinates of the mouse click 
> for the image. A way of retrieving these values through a form 
> bean is to define getX(), getY(), setX(), and setY() methods,
> and specify your propery as a blank string (property="").

ARG!  What if I *need* to use a named property to tell two images
apart??

If I use




They do indeed show up as "createButton.x=6" and "createButton.y=10",
when I dump the request.  However, my  setCreateButton() never gets
called.  I assume there's a "createButton.x" being tossed in the way. 
Mmking a methods called setCreateButtonX() didnt seem to help

Following the suggestion in the docs




I can then create "setX()" and "setY()" which do get called.  However,
I can no longer tell which button they pushed.. the create or the
delete button.  My webdesign folks will *never* let me use a generic
html submit button, it's GOT to be an image.  

Here's what I'd like, following the suggestions so far.

page.jsp
  
  

bean.jsp
  boolean createButton;
  public void setCreateButton__???___(String createButtonParm) {
   createButton = true;
  }
  public boolean isCreateButton() {
   return createButton;
  }

action.java
  if (formBean.isCreateButton()) 
 

I would really like to use the Form get/set method outlined above,
instead of scrolling thru the entire Request object looking for
parameters that start with "createButton.x".   It seems like I just
need to figure out how to name the setter/getter methods in my bean so
that the  tag actually calls the right part of the bean.

Currently Im looking thru the html:image taglib code...  urgh.

-tak


__
Do You Yahoo!?
Got something to say? Say it better with Yahoo! Video Mail 
http://mail.yahoo.com

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: HTML / Struts Help - addendum to summary.

2002-02-13 Thread Mattos, John

Did you try using 

Document.forms[0].testHidden.value instead? If that doesn't work, maybe you
could do it in a JavaScript function and then submit the form manually using
document.forms[0].submit (you'd have to make the submit button a regular
button that calls the method in the onclick)

You should be able to reference the .value of a hidden field from a
JavaScript function if nothing else.

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014

-Original Message-
From: Matt Koidin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 1:22 PM
To: Struts Users Mailing List
Subject: RE: HTML / Struts Help - addendum to summary.


I am trying to do something similar, except with an HTML link.

I have a hidden form field:


and then I try to set its value with an onclick function in my link:


Whenever I click the link, the testHidden field comes up as NULL. BUT,
when I use a regular submit button, it says the original "blah".

Any ideas what I am doing wrong?

-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 11:31 AM
To: 'Struts Users Mailing List'
Subject: RE: HTML / Struts Help - addendum to summary.


I like that solution.

I Think I'll alter my solution so that I'm doing it this way.
Originally, I
was concerned about getting back "Process Suspends" or some other
strange
string from 

String getBtnProcess() ( a method on the ActionForm class) within the
Action.perform() method, but then I realized I have access to the
message
resources, and that's where I'm getting that "Process Suspends" label
anyway, so why not just compare them.

I can therefore just do something like the following:

// Action.perform() snippet follows:
MessageResources application = actionServlet.getResources();
String thingToCompare =
application.getProperty(button.button.processSuspends);

I can then compare the results of getBtnProcess() with thingToCompare
and do
whatever I need to do.

Good catch, thanks

John

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014
-Original Message-
From: Keith [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 11:17 AM
To: Struts Users Mailing List
Subject: RE: HTML / Struts Help


I think the design of struts is that you should have get/setters in your
form
beans for the button parameters rather than look at the request parms
directly.

in form bean 
boolean createButton;
public void setCreateButton(String createButtonParm) {
createButton = true;
}
public boolean isCreateButton() {
return createButton;
}

in form bean reset have 
   createButton = false;
==
Then in your action code you can test
if (formBean.isCreateButton()) 
==
hope that helps
K.
--- "Andres Marcel (KASO 211)" <[EMAIL PROTECTED]> wrote:
> Hi John
> 
> You can use the  tag and set the property to a value.
> Then in the action, you are able to find out, which button was presed
like
> this :
> 
> // find out if the create button was clicked
> Enumeration enum = request.getParameterNames();
> int clickedButton = 0;
> for(int idx = 0; enum.hasMoreElements() & clickedButton == 0; idx++) {
>   String paramName = (String)enum.nextElement();
>   if(paramName.startsWith("VALUE-OF-PROPERTY-NAME")) {
>   // what ever you want to do
>   }
> }
> 
> 
> Marcel
> 
> -----Original Message-
> From: Mattos, John [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 4:12 PM
> To: '[EMAIL PROTECTED]'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for
example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find
out
> which button was pressed, and act accordingly, whether it's an
actionForward
> (in the case of the "view" options) or kicking off another process (as
will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class?
Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


=


__

RE: HTML / Struts Help - addendum to summary.

2002-02-13 Thread Matt Koidin

I am trying to do something similar, except with an HTML link.

I have a hidden form field:


and then I try to set its value with an onclick function in my link:


Whenever I click the link, the testHidden field comes up as NULL. BUT,
when I use a regular submit button, it says the original "blah".

Any ideas what I am doing wrong?

-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 11:31 AM
To: 'Struts Users Mailing List'
Subject: RE: HTML / Struts Help - addendum to summary.


I like that solution.

I Think I'll alter my solution so that I'm doing it this way.
Originally, I
was concerned about getting back "Process Suspends" or some other
strange
string from 

String getBtnProcess() ( a method on the ActionForm class) within the
Action.perform() method, but then I realized I have access to the
message
resources, and that's where I'm getting that "Process Suspends" label
anyway, so why not just compare them.

I can therefore just do something like the following:

// Action.perform() snippet follows:
MessageResources application = actionServlet.getResources();
String thingToCompare =
application.getProperty(button.button.processSuspends);

I can then compare the results of getBtnProcess() with thingToCompare
and do
whatever I need to do.

Good catch, thanks

John

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014
-Original Message-
From: Keith [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 11:17 AM
To: Struts Users Mailing List
Subject: RE: HTML / Struts Help


I think the design of struts is that you should have get/setters in your
form
beans for the button parameters rather than look at the request parms
directly.

in form bean 
boolean createButton;
public void setCreateButton(String createButtonParm) {
createButton = true;
}
public boolean isCreateButton() {
return createButton;
}

in form bean reset have 
   createButton = false;
==
Then in your action code you can test
if (formBean.isCreateButton()) 
==
hope that helps
K.
--- "Andres Marcel (KASO 211)" <[EMAIL PROTECTED]> wrote:
> Hi John
> 
> You can use the  tag and set the property to a value.
> Then in the action, you are able to find out, which button was presed
like
> this :
> 
> // find out if the create button was clicked
> Enumeration enum = request.getParameterNames();
> int clickedButton = 0;
> for(int idx = 0; enum.hasMoreElements() & clickedButton == 0; idx++) {
>   String paramName = (String)enum.nextElement();
>   if(paramName.startsWith("VALUE-OF-PROPERTY-NAME")) {
>   // what ever you want to do
>   }
> }
> 
> 
> Marcel
> 
> -Original Message-
> From: Mattos, John [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 4:12 PM
> To: '[EMAIL PROTECTED]'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for
example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find
out
> which button was pressed, and act accordingly, whether it's an
actionForward
> (in the case of the "view" options) or kicking off another process (as
will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class?
Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


=


__
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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

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


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




RE: HTML / Struts Help - addendum to summary.

2002-02-13 Thread Mattos, John

I like that solution.

I Think I'll alter my solution so that I'm doing it this way. Originally, I
was concerned about getting back "Process Suspends" or some other strange
string from 

String getBtnProcess() ( a method on the ActionForm class) within the
Action.perform() method, but then I realized I have access to the message
resources, and that's where I'm getting that "Process Suspends" label
anyway, so why not just compare them.

I can therefore just do something like the following:

// Action.perform() snippet follows:
MessageResources application = actionServlet.getResources();
String thingToCompare =
application.getProperty(button.button.processSuspends);

I can then compare the results of getBtnProcess() with thingToCompare and do
whatever I need to do.

Good catch, thanks

John

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014
-Original Message-
From: Keith [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 11:17 AM
To: Struts Users Mailing List
Subject: RE: HTML / Struts Help


I think the design of struts is that you should have get/setters in your
form
beans for the button parameters rather than look at the request parms
directly.

in form bean 
boolean createButton;
public void setCreateButton(String createButtonParm) {
createButton = true;
}
public boolean isCreateButton() {
return createButton;
}

in form bean reset have 
   createButton = false;
==
Then in your action code you can test
if (formBean.isCreateButton()) 
==
hope that helps
K.
--- "Andres Marcel (KASO 211)" <[EMAIL PROTECTED]> wrote:
> Hi John
> 
> You can use the  tag and set the property to a value.
> Then in the action, you are able to find out, which button was presed like
> this :
> 
> // find out if the create button was clicked
> Enumeration enum = request.getParameterNames();
> int clickedButton = 0;
> for(int idx = 0; enum.hasMoreElements() & clickedButton == 0; idx++) {
>   String paramName = (String)enum.nextElement();
>   if(paramName.startsWith("VALUE-OF-PROPERTY-NAME")) {
>   // what ever you want to do
>   }
> }
> 
> 
> Marcel
> 
> -Original Message-
> From: Mattos, John [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 4:12 PM
> To: '[EMAIL PROTECTED]'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for
example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an
actionForward
> (in the case of the "view" options) or kicking off another process (as
will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


=


__
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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

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




Re: HTML / Struts Help

2002-02-13 Thread Joel Barnum

John wrote:

> I have a form that can be submitted by three different buttons, for example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?

I'm not sure if this is struts-kosher, but it works. I have a form that 
includes two buttons:




Then I added get/set methods for a "submit" property in the associated 
FormBean. The Action class can then determine which button was pressed 
by calling getSubmit and doing a string compare:

String submit = myform.getSubmit();
if ( submit.equals ( "Forgot Password" ) )
{
   // etc...
}

Joel

-- 
-
 Descriptor Systems
   Java, C++ and XML Training and Courseware
 www.descriptor.com
 ICQ: 150414760
-


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: HTML / Struts Help

2002-02-13 Thread Keith

I think the design of struts is that you should have get/setters in your form
beans for the button parameters rather than look at the request parms directly.

in form bean 
boolean createButton;
public void setCreateButton(String createButtonParm) {
createButton = true;
}
public boolean isCreateButton() {
return createButton;
}

in form bean reset have 
   createButton = false;
==
Then in your action code you can test
if (formBean.isCreateButton()) 
==
hope that helps
K.
--- "Andres Marcel (KASO 211)" <[EMAIL PROTECTED]> wrote:
> Hi John
> 
> You can use the  tag and set the property to a value.
> Then in the action, you are able to find out, which button was presed like
> this :
> 
> // find out if the create button was clicked
> Enumeration enum = request.getParameterNames();
> int clickedButton = 0;
> for(int idx = 0; enum.hasMoreElements() & clickedButton == 0; idx++) {
>   String paramName = (String)enum.nextElement();
>   if(paramName.startsWith("VALUE-OF-PROPERTY-NAME")) {
>   // what ever you want to do
>   }
> }
> 
> 
> Marcel
> 
> -Original Message-
> From: Mattos, John [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 4:12 PM
> To: '[EMAIL PROTECTED]'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an actionForward
> (in the case of the "view" options) or kicking off another process (as will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


=


__
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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




RE: HTML / Struts Help - Summary

2002-02-13 Thread Mattos, John

Jay

Thanks a lot. To summarize, here is my HTML













and in my Action Class, I have the following
   String button_pressed = null;
   Enumeration e = request.getParameterNames();
   while (e.hasMoreElements()) {
   String param = (String) e.nextElement();
   if (param.startsWith("btn")) {
button_pressed = param;
   break;
   }
}

Works like a champ

Thanks a lot.

the other thing I found out I could have done, was, based on the SAME HTML
SNIPPET I could have a property on the ActionFormClass called BtnProcess
(with getter and setter) and I could get its value as follows 

// in the Action Form.perform()
ViewProcessSuspendsForm myForm=(ViewProcessSuspendsForm)form;
System.out.println("From the Action Form, getProcess(), the value is
"+myForm.getBtnProcess());

// Note, the value I get from this corresponds to  from the HTML, which is the label on the
button loaded from the resource file. It happens to be "Process Suspends". I
like the first solution better.

Anyway, thanks for all the responses and help.

John

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014
-Original Message-
From: Jay sissom [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:25 AM
To: Struts Users Mailing List
Subject: Re: HTML / Struts Help


You would do it the way you'd do it an any web application.

Here's how I do it:  All my button field names start with "btn".  I would 
name these buttons btnProcess, btnViewByOrg and btnViewByProcess (or 
something similar).

In my perform method, I'd put code like this:

   String button_pressed = null;
   Enumeration e = request.getParameterNames();
   while ( e.hasMoreElements() ) {
  String param = (String)e.nextElement();
  if ( param.startsWith("btn") ) {
 button_pressed = param;
 break;
  }
   }

At this point, button_pressed tells you the name of the button that was 
pressed.  I have a utility class that has this code in it and I use it 
everywhere.

Jay

On Wed, 13 Feb 2002, Mattos, John wrote:

> Hi.
> 
> I have a form that can be submitted by three different buttons, for
example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an
actionForward
> (in the case of the "view" options) or kicking off another process (as
will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


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

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




RE: HTML / Struts Help

2002-02-13 Thread Andres Marcel (KASO 211)

Hi John

You can use the  tag and set the property to a value.
Then in the action, you are able to find out, which button was presed like this :

// find out if the create button was clicked
Enumeration enum = request.getParameterNames();
int clickedButton = 0;
for(int idx = 0; enum.hasMoreElements() & clickedButton == 0; idx++) {
String paramName = (String)enum.nextElement();
if(paramName.startsWith("VALUE-OF-PROPERTY-NAME")) {
// what ever you want to do
}
}


Marcel

-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 4:12 PM
To: '[EMAIL PROTECTED]'
Subject: HTML / Struts Help


Hi.

I have a form that can be submitted by three different buttons, for example
the buttons read

(Button Labels)
Process
View by Org
View by Product

What I want to do is in the Action Class handling the submission, find out
which button was pressed, and act accordingly, whether it's an actionForward
(in the case of the "view" options) or kicking off another process (as will
be done by the "process" button)

So, how can I figure out what button was pressed in that Action class? Is
there a way to do that?

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014



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

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




RE: HTML / Struts Help

2002-02-13 Thread Jay sissom

This works, but then your users MUST have JavaScript enabled or your 
application will not work.

We try to build applications that work if users have JavaScript or don't 
have JavaScript.

It's just as easy to check this stuff on the server.  In your application, 
maybe you have full control over the browser, but in most web 
applications, the developers don't have control over the browser, so 
depending on JavaScript might not be such a good thing.

Just my opinion...

On Wed, 13 Feb 2002, Thompson, Darryl wrote:

> Hello,
> 
> When my JSPs contain multiple buttons that trigger different behaviour I use
> the DispatchAction...
> 
> Here is a snippet of html for defining a button:
> 
> onClick="window.location=\'dispatchSalesRequest.do?method=longDistance\'"/>
>
> onClick="window.location=\'dispatchSalesRequest.do?method=callingCards\'"/>
>//...
> 
>  In my struts-config.xml I create a mapping like this:
>  path="/dispatchSalesRequest"
>type="com.algx.coe.app.action.sales.DispatchSalesOrderSetup"
>name="SalesOrderForm"
>scope="request
>input="/pg_salesOrder_edit.jsp"
>parameter="method"
>validate="true">
>  path="/pg_acctCode_edit.jsp"/>
> 
>  path="/pg_callingCard_edit.jsp"/>
>  path="/pg_longDistance_edit.jsp"/>
> 
> 
> Then in the DispatchSalesOrderSetup class I handle any pre-page processing
> in an execute(...) method before 
> forwarding control to the appropriate page. The great thing about the
> DispatchAction class is you don't have to code any conditional logic since
> it uses
> reflection to map the request argument (in this case the  "method"
> parameter) value to a method name in the DispatchAction subclass.
> 
> Hope this helps...
> 
> / Darryl
> > -Original Message-
> > From:   Wijewickrema , Dina E. [SMTP:[EMAIL PROTECTED]]
> > Sent:   Wednesday, February 13, 2002 9:16 AM
> > To: 'Struts Users Mailing List'
> > Subject:RE: HTML / Struts Help
> > 
> > Just define a hidden field in your form. Then when you press a button
> > define
> > an onclick event that sets the value of the hidden field.
> > 
> > For example:
> > 
> > 
> > 
> >  > onclick="form.action.value='Process'">
> > 
> > -Original Message-
> > From: Mattos, John [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, February 13, 2002 10:12 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: HTML / Struts Help
> > 
> > 
> > Hi.
> > 
> > I have a form that can be submitted by three different buttons, for
> > example
> > the buttons read
> > 
> > (Button Labels)
> > Process
> > View by Org
> > View by Product
> > 
> > What I want to do is in the Action Class handling the submission, find out
> > which button was pressed, and act accordingly, whether it's an
> > actionForward
> > (in the case of the "view" options) or kicking off another process (as
> > will
> > be done by the "process" button)
> > 
> > So, how can I figure out what button was pressed in that Action class? Is
> > there a way to do that?
> > 
> > John Mattos
> > Sr. Developer and Architect
> > iNDEMAND
> > 345 Hudson St. 16th Floor
> > New York, New York
> > 10014
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


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




RE: HTML / Struts Help

2002-02-13 Thread geert

you can set the property on the submit button and then use request.getParameter 
to get the value of the propery in your action.

example : 


  
  
  


In the perform method of your action you can then write : 
  String s = request.getParameter("toDo");
  if ( s.equals("process"))
  process();
  else if ( s.equals("view by org"))
  viewByOrg();
  else if ( s.equals("view by product"))
  viewByProduct();

Greetings,
Geert.

-- 
Get your firstname@lastname email at http://Nameplanet.com/?su

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




AW: HTML / Struts Help

2002-02-13 Thread Oliver Reflé

if you want to user javascript do it like this,
import your buttons as image and use it as a hyperlink


Details

maybe it`s not the best solution, but you can now redirect to different
actions for different buttons,
you can change parameters in the url and so on
-Ursprüngliche Nachricht-
Von: Mattos, John [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 13. Februar 2002 16:42
An: 'Struts Users Mailing List'
Betreff: RE: HTML / Struts Help


Hey

I was thinking about that (I actually have a hidden field already called
"toDo" (still working on that name)) but the problem is that it has to
change based on which button is pressed.

I could use JavaScript to set the hidden field dynamically (I don't know if
this will work with struts, but I think I can do
document.forms[0].toDo.value="process" (or whatever) but I'd rather just
have the buttons submit then be able to sort out what was pressed in the
perform method



John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014

(w) (646) 638-8391
(f) (800) 877-5301
(c) (917) 202-8450
(w) www.iNDEMAND.com

This e-mail contains privileged and/or confidential information intended for
the use of the addressee. If the reader of this e-mail is not the intended
recipient, you have received this e-mail in error and any review,
dissemination, distribution or copying is strictly prohibited. If you have
received this e-mail in error, please notify the sender immediately by
return e-mail and permanently delete the copy you received. Thank you.


-Original Message-
From: Wijewickrema , Dina E. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:16 AM
To: 'Struts Users Mailing List'
Subject: RE: HTML / Struts Help


Just define a hidden field in your form. Then when you press a button define
an onclick event that sets the value of the hidden field.

For example:





-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:12 AM
To: '[EMAIL PROTECTED]'
Subject: HTML / Struts Help


Hi.

I have a form that can be submitted by three different buttons, for example
the buttons read

(Button Labels)
Process
View by Org
View by Product

What I want to do is in the Action Class handling the submission, find out
which button was pressed, and act accordingly, whether it's an actionForward
(in the case of the "view" options) or kicking off another process (as will
be done by the "process" button)

So, how can I figure out what button was pressed in that Action class? Is
there a way to do that?

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014



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

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

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


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




RE: HTML / Struts Help

2002-02-13 Thread Mattos, John

Hey

I was thinking about that (I actually have a hidden field already called
"toDo" (still working on that name)) but the problem is that it has to
change based on which button is pressed.

I could use JavaScript to set the hidden field dynamically (I don't know if
this will work with struts, but I think I can do
document.forms[0].toDo.value="process" (or whatever) but I'd rather just
have the buttons submit then be able to sort out what was pressed in the
perform method



John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014

(w) (646) 638-8391
(f) (800) 877-5301
(c) (917) 202-8450
(w) www.iNDEMAND.com

This e-mail contains privileged and/or confidential information intended for
the use of the addressee. If the reader of this e-mail is not the intended
recipient, you have received this e-mail in error and any review,
dissemination, distribution or copying is strictly prohibited. If you have
received this e-mail in error, please notify the sender immediately by
return e-mail and permanently delete the copy you received. Thank you. 


-Original Message-
From: Wijewickrema , Dina E. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:16 AM
To: 'Struts Users Mailing List'
Subject: RE: HTML / Struts Help


Just define a hidden field in your form. Then when you press a button define
an onclick event that sets the value of the hidden field.

For example:





-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:12 AM
To: '[EMAIL PROTECTED]'
Subject: HTML / Struts Help


Hi.

I have a form that can be submitted by three different buttons, for example
the buttons read

(Button Labels)
Process
View by Org
View by Product

What I want to do is in the Action Class handling the submission, find out
which button was pressed, and act accordingly, whether it's an actionForward
(in the case of the "view" options) or kicking off another process (as will
be done by the "process" button)

So, how can I figure out what button was pressed in that Action class? Is
there a way to do that?

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014



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

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

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




RE: HTML / Struts Help

2002-02-13 Thread Thompson, Darryl

Hello,

When my JSPs contain multiple buttons that trigger different behaviour I use
the DispatchAction...

Here is a snippet of html for defining a button:
 

   //...

 In my struts-config.xml I create a mapping like this:
   
  
  
  
  


Then in the DispatchSalesOrderSetup class I handle any pre-page processing
in an execute(...) method before 
forwarding control to the appropriate page. The great thing about the
DispatchAction class is you don't have to code any conditional logic since
it uses
reflection to map the request argument (in this case the  "method"
parameter) value to a method name in the DispatchAction subclass.

Hope this helps...

/ Darryl
> -Original Message-
> From: Wijewickrema , Dina E. [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 9:16 AM
> To:   'Struts Users Mailing List'
> Subject:  RE: HTML / Struts Help
> 
> Just define a hidden field in your form. Then when you press a button
> define
> an onclick event that sets the value of the hidden field.
> 
> For example:
> 
> 
> 
>  onclick="form.action.value='Process'">
> 
> -Original Message-
> From: Mattos, John [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 10:12 AM
> To: '[EMAIL PROTECTED]'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for
> example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an
> actionForward
> (in the case of the "view" options) or kicking off another process (as
> will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>

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




RE: HTML / Struts Help

2002-02-13 Thread Galbreath, Mark

Name the buttons and give them a value; the name and value associated with
the submit will be passed as a request parameter: 

private doSomething( request.getParameter( "buttonName"));

Cheers!
Mark

--
Try before you cry:
http://www.mail-archive.com/struts-user%40jakarta.apache.org/


-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:12 AM

So, how can I figure out what button was pressed in that Action class? Is
there a way to do that?

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: HTML / Struts Help

2002-02-13 Thread Jay sissom

You would do it the way you'd do it an any web application.

Here's how I do it:  All my button field names start with "btn".  I would 
name these buttons btnProcess, btnViewByOrg and btnViewByProcess (or 
something similar).

In my perform method, I'd put code like this:

   String button_pressed = null;
   Enumeration e = request.getParameterNames();
   while ( e.hasMoreElements() ) {
  String param = (String)e.nextElement();
  if ( param.startsWith("btn") ) {
 button_pressed = param;
 break;
  }
   }

At this point, button_pressed tells you the name of the button that was 
pressed.  I have a utility class that has this code in it and I use it 
everywhere.

Jay

On Wed, 13 Feb 2002, Mattos, John wrote:

> Hi.
> 
> I have a form that can be submitted by three different buttons, for example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an actionForward
> (in the case of the "view" options) or kicking off another process (as will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: HTML / Struts Help

2002-02-13 Thread Wijewickrema , Dina E.

Just define a hidden field in your form. Then when you press a button define
an onclick event that sets the value of the hidden field.

For example:





-Original Message-
From: Mattos, John [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 10:12 AM
To: '[EMAIL PROTECTED]'
Subject: HTML / Struts Help


Hi.

I have a form that can be submitted by three different buttons, for example
the buttons read

(Button Labels)
Process
View by Org
View by Product

What I want to do is in the Action Class handling the submission, find out
which button was pressed, and act accordingly, whether it's an actionForward
(in the case of the "view" options) or kicking off another process (as will
be done by the "process" button)

So, how can I figure out what button was pressed in that Action class? Is
there a way to do that?

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014



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

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




HTML / Struts Help

2002-02-13 Thread Mattos, John

Hi.

I have a form that can be submitted by three different buttons, for example
the buttons read

(Button Labels)
Process
View by Org
View by Product

What I want to do is in the Action Class handling the submission, find out
which button was pressed, and act accordingly, whether it's an actionForward
(in the case of the "view" options) or kicking off another process (as will
be done by the "process" button)

So, how can I figure out what button was pressed in that Action class? Is
there a way to do that?

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014



--
To unsubscribe, e-mail:   
For additional commands, e-mail: