Using the template tag library with parameters like jsp:param

2002-08-31 Thread CB Thomas

With jsp:include, I can pass parameter values to the included page by using 
jsp:param.

Can I get this functionality using the Struts template tag library?  If so, 
can I use request.getParameter to retrieve values in the included page?

_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




Re: Using the template tag library with parameters like jsp:param

2002-08-31 Thread David Geary

CB Thomas wrote:

 With jsp:include, I can pass parameter values to the included page by 
 using jsp:param.

 Can I get this functionality using the Struts template tag library?

Yes. Use the direct attribute, like this:

template:put name='title' content='Templates' direct='true'/

Then in your template, you can access that value; for example, like this:

htmlheadtitletemplate:get name='title'//title/head.../html

Normally, the template:get tag will include content associated with 
the named parameter, but if you
specify direct='true' with template:put, the template:get tag will 
just retrieve the value.

See http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-jspweb_p.html 
for more information about templates and the direct attribute.

btw, if at all possible, I suggest that you use Tiles instead of 
templates. The former, which is an extension of the latter, has more 
functionality.

   If so, can I use request.getParameter to retrieve values in the 
 included page? 

No, but you can use template:get as illustrated above.


david



 _
 Chat with friends online, try MSN Messenger: http://messenger.msn.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: Using the template tag library with parameters like jsp:param

2002-08-31 Thread Eddie Bush

There is also Tiles for this sort of thing.

David Geary wrote:

 CB Thomas wrote:

 With jsp:include, I can pass parameter values to the included page by 
 using jsp:param.

 Can I get this functionality using the Struts template tag library?

 Yes. Use the direct attribute, like this: 

Tiles is a more feature-rich version of the template mechanism in 
Struts.  It supports this as well.

 template:put name='title' content='Templates' direct='true'/

 Then in your template, you can access that value; for example, like this:

 htmlheadtitletemplate:get name='title'//title/head.../html

 Normally, the template:get tag will include content associated with 
 the named parameter, but if you
 specify direct='true' with template:put, the template:get tag will 
 just retrieve the value.

 See 
 http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-jspweb_p.html 
 for more information about templates and the direct attribute.

 btw, if at all possible, I suggest that you use Tiles instead of 
 templates. The former, which is an extension of the latter, has more 
 functionality.

   If so, can I use request.getParameter to retrieve values in the 
 included page? 

 No, but you can use template:get as illustrated above.

 david 

Regards,

Eddie



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




Re: Using the template tag library with parameters like jsp:param

2002-08-31 Thread jw

Hi All!

I've seen a number of posts looking for help/info on the this type of error message 
(i.e., javax.servlet.ServletException: Exception creating bean of class 
???.???.xxxForm: java.lang.ClassNotFoundException: ???.???.xxxForm) that occurs when 
they attempt to test their struts application.

I have not seen a solution/ explanation, thus far, as to why this occurs.

Any help or insight as to why this happens, would be much appreciated.   Once again, 
I'm cutting and pasting a code example - that theoretically should work 
out-of-the-box, and once again its not working (whaddya gonna do?)..

Here is the information/example code that I'm trying to get working when this error 
occurs... (NOTE: I'm using jakarta-tomcat-4.0.4,j2sdk1.4.0_01,
jakarta-struts-1.0.2)

*** SubmitForm.java***
package hansen.playground;

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

public final class SubmitForm extends ActionForm {

  /* Last Name */
  private String lastName = Hansen; // default value
  public String getLastName() {
return (this.lastName);
  }
  public void setLastName(String lastName) {
this.lastName = lastName;
  }

  /* Address */
  private String address = null;
  public String getAddress() {
return (this.address);
  }
  public void setAddress(String address) {
this.address = address;
  }

  /* Sex */
  private String sex = null;
  public String getSex() {
return (this.sex);
  }
  public void setSex(String sex) {
this.sex = sex;
  }

  /* Married status */
  private String married = null;
  public String getMarried() {
return (this.married);
  }
  public void setMarried(String married) {
this.married = married;
  }

  /* Age */
  private String age = null;
  public String getAge() {
return (this.age);
  }
  public void setAge(String age) {
this.age = age;
  }

}


*** SubmitAction.java ***
package hansen.playground;

import javax.servlet.http.*;
import org.apache.struts.action.*;

public final class SubmitAction extends Action {

  public ActionForward perform(ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) {

SubmitForm f = (SubmitForm) form; // get the form bean
// and take the last name value
String lastName = f.getLastName();
// Translate the name to upper case
//and save it in the request object
request.setAttribute(lastName, lastName.toUpperCase());

// Forward control to the specified success target
return (mapping.findForward(success));
  }
}

*** submit.jsp***
% page language=java %
% taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
% taglib uri=/WEB-INF/struts-html.tld prefix=html %
% taglib uri=/WEB-INF/struts-logic.tld prefix=logic %

html
headtitleSubmit example/title/head
body

h3Example Submit Page/h3

html:errors/

html:form action=submit.do
Last Name: html:text property=lastName/br
Address:   html:textarea property=address/br
Sex:   html:radio property=sex value=M/Male
   html:radio property=sex value=F/Femalebr
Married:   html:checkbox property=married/br
Age:   html:select property=age
 html:option value=a0-19/html:option
 html:option value=b20-49/html:option
 html:option value=c50-/html:option
   /html:selectbr
   html:submit/
/html:form

/body
/html


*** struts-config.xml ***
?xml version=1.0 encoding=ISO-8859-1 ?
!DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts 
Configuration 1.0//EN http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

struts-config


  !-- == Form Bean Definitions === --
  form-beans
form-bean name=submitForm type=hansen.playground.SubmitForm
/form-bean
  /form-beans


  !-- == Global Forward Definitions == --
  global-forwards
  /global-forwards


  !-- == Action Mapping Definitions == --
  action-mappings

action   path=/submit
  type=hansen.playground.SubmitAction
  name=submitForm
  input=/submit.jsp
  scope=request
forward name=success path=/submit.jsp/  
forward name=failure path=/submit.jsp/  
/action


  /action-mappings

/struts-config

*** ***

jw


*** error that I receive ***

javax.servlet.ServletException: Exception creating bean of class 
hansen.playground.SubmitForm: java.lang.ClassNotFoundException: 
hansen.playground.SubmitForm
at 
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.submit$jsp._jspService(submit$jsp.java:485)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at 

Re: Using the template tag library with parameters like jsp:param

2002-08-31 Thread jw

Hi All

Sorry for the bother - but, who knew - i.e., The issue was apparently
related to the struts version I was using (i.e.,
jakarta-struts-1.0.2)...

Apparently, the examples will work only with jakarta-struts-1.1-b2.At
least in my current environment (winXP/j2sdk1.4.0_01/jakarta-tomcat-4.0.4)

Thanks!

jw
- Original Message -
From: jw [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Saturday, August 31, 2002 1:28 PM
Subject: Re: Using the template tag library with parameters like jsp:param


Hi All!

I've seen a number of posts looking for help/info on the this type of error
message (i.e., javax.servlet.ServletException: Exception creating bean of
class ???.???.xxxForm: java.lang.ClassNotFoundException: ???.???.xxxForm)
that occurs when they attempt to test their struts application.

I have not seen a solution/ explanation, thus far, as to why this occurs.

Any help or insight as to why this happens, would be much appreciated.
Once again, I'm cutting and pasting a code example - that theoretically
should work out-of-the-box, and once again its not working (whaddya gonna
do?)..

Here is the information/example code that I'm trying to get working when
this error occurs... (NOTE: I'm using jakarta-tomcat-4.0.4,
j2sdk1.4.0_01,jakarta-struts-1.0.2)

*** SubmitForm.java***
package hansen.playground;

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

public final class SubmitForm extends ActionForm {

  /* Last Name */
  private String lastName = Hansen; // default value
  public String getLastName() {
return (this.lastName);
  }
  public void setLastName(String lastName) {
this.lastName = lastName;
  }

  /* Address */
  private String address = null;
  public String getAddress() {
return (this.address);
  }
  public void setAddress(String address) {
this.address = address;
  }

  /* Sex */
  private String sex = null;
  public String getSex() {
return (this.sex);
  }
  public void setSex(String sex) {
this.sex = sex;
  }

  /* Married status */
  private String married = null;
  public String getMarried() {
return (this.married);
  }
  public void setMarried(String married) {
this.married = married;
  }

  /* Age */
  private String age = null;
  public String getAge() {
return (this.age);
  }
  public void setAge(String age) {
this.age = age;
  }

}


*** SubmitAction.java ***
package hansen.playground;

import javax.servlet.http.*;
import org.apache.struts.action.*;

public final class SubmitAction extends Action {

  public ActionForward perform(ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) {

SubmitForm f = (SubmitForm) form; // get the form bean
// and take the last name value
String lastName = f.getLastName();
// Translate the name to upper case
//and save it in the request object
request.setAttribute(lastName, lastName.toUpperCase());

// Forward control to the specified success target
return (mapping.findForward(success));
  }
}

*** submit.jsp***
%@ page language=java %
%@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
%@ taglib uri=/WEB-INF/struts-html.tld prefix=html %
%@ taglib uri=/WEB-INF/struts-logic.tld prefix=logic %

html
headtitleSubmit example/title/head
body

h3Example Submit Page/h3

html:errors/

html:form action=submit.do
Last Name: html:text property=lastName/br
Address:   html:textarea property=address/br
Sex:   html:radio property=sex value=M/Male
   html:radio property=sex value=F/Femalebr
Married:   html:checkbox property=married/br
Age:   html:select property=age
 html:option value=a0-19/html:option
 html:option value=b20-49/html:option
 html:option value=c50-/html:option
   /html:selectbr
   html:submit/
/html:form

/body
/html


*** struts-config.xml ***
?xml version=1.0 encoding=ISO-8859-1 ?
!DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts
Configuration 1.0//EN
http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

struts-config


  !-- == Form Bean Definitions
=== --
  form-beans
form-bean name=submitForm type=hansen.playground.SubmitForm
/form-bean
  /form-beans


  !-- == Global Forward Definitions
== --
  global-forwards
  /global-forwards


  !-- == Action Mapping Definitions
== --
  action-mappings

action   path=/submit
  type=hansen.playground.SubmitAction
  name=submitForm
  input=/submit.jsp
  scope=request
forward name=success path=/submit.jsp/
forward name=failure path=/submit.jsp/
/action


  /action-mappings

/struts-config

*** ***

jw


*** error that I receive ***

javax.servlet.ServletException: Exception creating bean of class
hansen.playground.SubmitForm