How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Mehran Zonouzi
Hi,

I have the following link in my JSP page:

td width=130a href=/servlets/blotter/Contact?page=viewcontactlist 
target=rightframe class=linkboldContact List/a/td

I want to mimic the above using Struts JSP tags(I don't want to use a SUBMIT button). 
However, I want to call my ActionForm class instead of the servlet and I would like to 
set the value of the param 'page' to 'viewcontactlist' for my ActionForm class so that 
my Action class can use it.

Is it possible to do this?


Here is my ActionForm implementation:

import javax.servlet.http.HttpServletRequest;
import org.apache.strus.action.*;

public final class ContactForm extends ActionForm {

  // page parameter from the CDS menu

  private String pageName =null;
  public String getPageName(){
return (this.pageName);
  }

  public void setPageName(String pageName){
this.pageName = pageName;
  }
}




--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



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



RE: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread James Childers

 -Original Message-
 From: Mehran Zonouzi [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 09, 2003 8:24 AM
 To: Struts Users Mailing List
 Subject: How do you mimic the 'a href' functionality in Struts?
 
 td width=130a 
 href=/servlets/blotter/Contact?page=viewcontactlist 
 target=rightframe class=linkboldContact List/a/td
 
 I want to mimic the above using Struts JSP tags(I don't want 
 to use a SUBMIT button). However, I want to call my 
 ActionForm class instead of the servlet and I would like to 
 set the value of the param 'page' to 'viewcontactlist' for my 
 ActionForm class so that my Action class can use it.
 
 Is it possible to do this?

Yes.

Your href attribute can point to a JavaScript function that sets some hidden form 
variables then submits the form. It would look something like this:

script type=text/javascript
function submitFunctionForYou(lType) {
document.yerForm.elements[page].value = lType;
}
/script

td
html:form action=/yerAction
html:hidden property=page /
/html:form
a href=submitFunctionForYou('viewcontactlist'); return true;Contact 
List/a
/td

-= J

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



Re: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Joe Germuska
In general, you use the html:link tag

http://jakarta.apache.org/struts/userGuide/struts-html.html#link

For the destination of the link, it takes one of four attributes: 
forward, action, href, or page.

The mechanism for specifying a single parameter for the link uses 
these attributes: paramId, paramName, paramProperty, paramScope

The value of paramId is the request parameter name.  In your HTML 
sample, then, this would be page, although in your ActionForm, this 
would probably be pageName.  (You probably want those to be 
consistent with each other.)

You can specify the value for the parameter with the appropriate 
combination of paramName, paramProperty, and paramScope, with 
semantics analogous to name, property, and scope in the various 
bean tags.

If you need to specify multiple parameters, this is done with a map 
whose keys are parameter names and whose values are the values to be 
put in the URL.  See the docs for more details.

However, I'm guessing from your example link that you'd pass the same 
parameter in the link every time -- that is, you'd always want the 
text Contact List linked to the same URL.  In this case, the better 
Struts way to do it would be to define different action mappings 
for each of the various parameters you would pass.  This leaves you a 
lot of future flexibility about how the functionality is provided. 
If necessary, you could write a separate Struts Action class for each 
mapping, or you could use one action for several mappings and use an 
action mapping parameter to dispatch execution to a 
parameter-specific method inside the action.

Hope this helps.

Joe

At 14:23 +0100 9/9/03, Mehran Zonouzi wrote:
Hi,

I have the following link in my JSP page:

td width=130a 
href=/servlets/blotter/Contact?page=viewcontactlist 
target=rightframe class=linkboldContact List/a/td

I want to mimic the above using Struts JSP tags(I don't want to use 
a SUBMIT button). However, I want to call my ActionForm class 
instead of the servlet and I would like to set the value of the 
param 'page' to 'viewcontactlist' for my ActionForm class so that my 
Action class can use it.

Is it possible to do this?

Here is my ActionForm implementation:

import javax.servlet.http.HttpServletRequest;
import org.apache.strus.action.*;
public final class ContactForm extends ActionForm {

  // page parameter from the CDS menu

  private String pageName =null;
  public String getPageName(){
return (this.pageName);
  }
  public void setPageName(String pageName){
this.pageName = pageName;
  }
}


--

This e-mail may contain confidential and/or privileged information. 
If you are not the intended recipient (or have received this e-mail 
in error) please notify the sender immediately and destroy this 
e-mail. Any unauthorized copying, disclosure or distribution of the 
material in this e-mail is strictly forbidden.



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


--
--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
If nature worked that way, the universe would crash all the time. 
	--Jaron Lanier

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


Re: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Mehran Zonouzi

Yes I am going to pass the same param to the link every time.

This is what I have replaced the link with.
I am not too sure if I should be using the href
property to call my ActionForm class.

html:link href=ContactForm paramId=page paramName=viewcontactlist




   

  Joe Germuska 

  [EMAIL PROTECTED]To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  cc: 

   Subject:  Re: How do you mimic the 'a 
href' functionality in Struts?
  09/09/03 14:47   

  Please respond to

  Struts Users

  Mailing List

   

   





In general, you use the html:link tag

http://jakarta.apache.org/struts/userGuide/struts-html.html#link


For the destination of the link, it takes one of four attributes:
forward, action, href, or page.

The mechanism for specifying a single parameter for the link uses
these attributes: paramId, paramName, paramProperty, paramScope

The value of paramId is the request parameter name.  In your HTML
sample, then, this would be page, although in your ActionForm, this
would probably be pageName.  (You probably want those to be
consistent with each other.)

You can specify the value for the parameter with the appropriate
combination of paramName, paramProperty, and paramScope, with
semantics analogous to name, property, and scope in the various
bean tags.

If you need to specify multiple parameters, this is done with a map
whose keys are parameter names and whose values are the values to be
put in the URL.  See the docs for more details.


However, I'm guessing from your example link that you'd pass the same
parameter in the link every time -- that is, you'd always want the
text Contact List linked to the same URL.  In this case, the better
Struts way to do it would be to define different action mappings
for each of the various parameters you would pass.  This leaves you a
lot of future flexibility about how the functionality is provided.
If necessary, you could write a separate Struts Action class for each
mapping, or you could use one action for several mappings and use an
action mapping parameter to dispatch execution to a
parameter-specific method inside the action.

Hope this helps.

Joe


At 14:23 +0100 9/9/03, Mehran Zonouzi wrote:
Hi,

I have the following link in my JSP page:

td width=130a
href=/servlets/blotter/Contact?page=viewcontactlist
target=rightframe class=linkboldContact List/a/td

I want to mimic the above using Struts JSP tags(I don't want to use
a SUBMIT button). However, I want to call my ActionForm class
instead of the servlet and I would like to set the value of the
param 'page' to 'viewcontactlist' for my ActionForm class so that my
Action class can use it.

Is it possible to do this?


Here is my ActionForm implementation:

import javax.servlet.http.HttpServletRequest;
import org.apache.strus.action.*;

public final class ContactForm extends ActionForm {

   // page parameter from the CDS menu

   private String pageName =null;
   public String getPageName(){
   }

   public void setPageName(String pageName){
   }
}




--

This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail
in error) please notify the sender immediately and destroy this
e-mail. Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.



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


--
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
If nature worked that way, the universe would crash all the time.
 --Jaron Lanier

-
To unsubscribe, e

Re: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Joe Germuska
At 15:03 +0100 9/9/03, Mehran Zonouzi wrote:
Yes I am going to pass the same param to the link every time.

This is what I have replaced the link with.
I am not too sure if I should be using the href
property to call my ActionForm class.
html:link href=ContactForm paramId=page paramName=viewcontactlist
At first encounter, the distinctions between the various link 
destination attributes can be a little confusing -- but you probably 
don't want to use href in this case.

If you have a specific action mapping called /ContactForm then you 
should use 'action=/ContactForm'  You would generally only want to 
use href when you were linking outside of your web application -- 
the other three provide dynamic URL rewriting to prepend the 
application context path so that you can deploy the same web app 
under different context paths without having to change your JSPs... 
(Other tags like html:img provide similar rewriting...)

The below is copied from the docs for this tag:

The base URL for this hyperlink is calculated based on which of the 
following attributes you specify (you must specify exactly one of 
them):

* forward - Use the value of this attribute as the name of a global 
ActionForward to be looked up, and use the 
application-relative or context-relative URI found there.

* action - Use the value of this attribute as the name of a Action to 
be looked up, and use the application-relative or context-relative 
URI found there.

* href - Use the value of this attribute unchanged.

* page - Use the value of this attribute as a application-relative 
URI, and generate a server-relative URI by 
including the context path and application prefix.

Joe



--
--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
If nature worked that way, the universe would crash all the time. 
	--Jaron Lanier

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


Re: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Mehran Zonouzi

Does the name I use for action i.e ContactForm have to tie in with what I use in the 
struts-config.xml file?

html:link action=/ContactForm paramId=page paramName=viewcontactlist 
paramScope=request

i.e.
Do I need to put ContactForm instead of 'contacts' for path...

 action path=/contacts
   type=com.db.gcp.lemweb.blotter.servlets.ContactAction
   name=contactForm
   input=/viewcontactlist.jsp
   scope=request
   /action










   

  Joe Germuska 

  [EMAIL PROTECTED]To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  cc: 

   Subject:  Re: How do you mimic the 'a 
href' functionality in Struts?
  09/09/03 17:53   

  Please respond to

  Struts Users

  Mailing List

   

   





At 15:03 +0100 9/9/03, Mehran Zonouzi wrote:
Yes I am going to pass the same param to the link every time.

This is what I have replaced the link with.
I am not too sure if I should be using the href
property to call my ActionForm class.

html:link href=ContactForm paramId=page paramName=viewcontactlist

At first encounter, the distinctions between the various link
destination attributes can be a little confusing -- but you probably
don't want to use href in this case.

If you have a specific action mapping called /ContactForm then you
should use 'action=/ContactForm'  You would generally only want to
use href when you were linking outside of your web application --
the other three provide dynamic URL rewriting to prepend the
application context path so that you can deploy the same web app
under different context paths without having to change your JSPs...
(Other tags like html:img provide similar rewriting...)

The below is copied from the docs for this tag:

The base URL for this hyperlink is calculated based on which of the
following attributes you specify (you must specify exactly one of
them):

* forward - Use the value of this attribute as the name of a global
ActionForward to be looked up, and use the
application-relative or context-relative URI found there.

* action - Use the value of this attribute as the name of a Action to
be looked up, and use the application-relative or context-relative
URI found there.

* href - Use the value of this attribute unchanged.

* page - Use the value of this attribute as a application-relative
URI, and generate a server-relative URI by
including the context path and application prefix.

Joe



--
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
If nature worked that way, the universe would crash all the time.
 --Jaron Lanier

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






--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



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



RE: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Slattery, Tim - BLS
 i.e.
 Do I need to put ContactForm instead of 'contacts' for path...
 
  action path=/contacts
type=com.db.gcp.lemweb.blotter.servlets.ContactAction
name=contactForm
input=/viewcontactlist.jsp
scope=request
/action


No, contacts is the URL that the browser asks for to invoke your
ContactAction class. ContactForm is the FormBean (explicitly defined
elsewhere in the struts-config.xml file) that will be passed to the
ContactAction class. Therefore, ContactForm should be the form bean used by
the form in viewcontactlist.jsp.

--
Tim Slattery
[EMAIL PROTECTED]


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



Re: How do you mimic the 'a href' functionality in Struts?

2003-09-09 Thread Joe Germuska
The action attribute of the html:link tag and the path attribute 
of the action element should be identical.

Note that  the value of the paramName attribute (viewcontactlist 
in your example)  is not a string literal, but rather the name of a 
bean in some scope (page, request, session, or application) which 
will be looked up and converted to a string as the value of the 
parameter.  In your case, since you specify paramScope=request, the 
tag will specifically call request.getAttribute(viewcontactlist) 
to get the value.

Joe

At 18:02 +0100 9/9/03, Mehran Zonouzi wrote:
Does the name I use for action i.e ContactForm have to tie in with 
what I use in the struts-config.xml file?

html:link action=/ContactForm paramId=page 
paramName=viewcontactlist paramScope=request

i.e.
Do I need to put ContactForm instead of 'contacts' for path...
 action path=/contacts
   type=com.db.gcp.lemweb.blotter.servlets.ContactAction
   name=contactForm
   input=/viewcontactlist.jsp
   scope=request
   /action
--
--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
If nature worked that way, the universe would crash all the time. 
	--Jaron Lanier

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