Re: Struts + Tiles..

2002-02-20 Thread Tuomo Syvänperä

Okay... Seems to be a problem with tomcat. I tried the same thing with 
orion and it works like a charm. Anybody now about this kind of bug in 
tomcat ? Or is it a bug or a feature :)

/tuomo

Tuomo Syvänperä wrote:
> Hi..
> I know you must be sick and tired of these stupid questions about struts 
> & tiles but I have a problem (imagine that).
> I keep getting java.lang.IllegalStateException from tomcat when using 
> tiles. At first I thought I had just done something wrong when using 
> tiles, but it seems that even a simple page as described below throws 
> this exception.
> I have a test.jsp file:
> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles"%>
> 
> 
> 
> 
> 
> 
> 
> And foo.jsp only includes the line 'foo' in it.
> 
> Now when I access the page test.jsp I get the following error:
> [12:46:48,164,EmbeddedCatalinaServiceSX] 
> ApplicationDispatcher[/emedia.war] Servlet.service() for servlet default 
> threw exception
> java.lang.IllegalStateException
> at 
> 
>org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:109)
> 
> 
> at 
> org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:1143) 
> 
> at 
> org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:519)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> 
>org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679) 
> 
> at 
> 
>org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:570)
> 
> 
> at 
> 
>org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:493)
> 
> 
> at 
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:818) 
> 
> at 
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:390)
> at 
> org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:757) 
> 
> at 
> org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:369)
> at org.apache.jsp.test$jsp._jspService(test$jsp.java:73)
> 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:202) 
> 
> at 
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> [SNIP]
> 
> I'm using JBoss 2.4.4 with embedded Tomcat 4.0.1 and using the latest 
> (20020219) nightly build of struts and latest development build of tiles 
> which I downloaded from tiles homepage.
> I have defined the controller as TilesRequestProcessor in 
> struts-config.xml and in web.xml I have ActionComponentServlet as the 
> action component.
> 
> Thanks.
> Tuomo
> 
> 
> -- 
> 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]>




Struts + Tiles..

2002-02-20 Thread Tuomo Syvänperä

Hi..
I know you must be sick and tired of these stupid questions about struts 
& tiles but I have a problem (imagine that).
I keep getting java.lang.IllegalStateException from tomcat when using 
tiles. At first I thought I had just done something wrong when using 
tiles, but it seems that even a simple page as described below throws 
this exception.
I have a test.jsp file:
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles"%>







And foo.jsp only includes the line 'foo' in it.

Now when I access the page test.jsp I get the following error:
[12:46:48,164,EmbeddedCatalinaServiceSX] 
ApplicationDispatcher[/emedia.war] Servlet.service() for servlet default 
threw exception
java.lang.IllegalStateException
at 
org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:109)
at 
org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:1143)
at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:519)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
at 
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:570)
at 
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:493)
at 
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:818)
at 
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:390)
at 
org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:757)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:369)
at org.apache.jsp.test$jsp._jspService(test$jsp.java:73)
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:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[SNIP]

I'm using JBoss 2.4.4 with embedded Tomcat 4.0.1 and using the latest 
(20020219) nightly build of struts and latest development build of tiles 
which I downloaded from tiles homepage.
I have defined the controller as TilesRequestProcessor in 
struts-config.xml and in web.xml I have ActionComponentServlet as the 
action component.

Thanks.
Tuomo


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




Re: struts-config.xml-Is there a tool to find errors in it?

2001-12-19 Thread Tuomo Syvänperä

The problem only came up occasionally. If I had two webapps and I 
started the servlet container and accessed one of them, it works fine. 
If after that I try to access the other one, it gives the error below.
Everything has worked fine since I switched back to 1.3 JDK.

/tuomo

[EMAIL PROTECTED] wrote:

> Yes I am using 1.4beta.  But an almost identical webapp works with 
> 1.4beta.  Strange I say.
> 
> 
> 
> Tuomo Syvänperä wrote:
> 
>> Hi Antony,
>> Are you using Sun's JDK 1.4 beta.. I got the same 'object is not an 
>> instance of declaring class' - error when I used JDK 1.4.
>> Try switching to 1.3
>>
>> /tuomo
>>
>> [EMAIL PROTECTED] wrote:
>>
>>> Here is the part of the debug log which shows the error
>>>
>>> ---start tomcat log--
>>> [snip]
>>> resolveEntity('-//Apache Software Foundation//DTD Struts 
>>> Configuration 1.0//EN', 
>>> 'http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd')
>>>  Resolving to alternate DTD 
>>> 
>'jar:file:/var/tomcat4/webapps/sturdy/WEB-INF/lib/struts.jar!/org/apache/struts/resources/struts-config_1_0.dtd'
> 
>>>
>>> New org.apache.struts.action.ActionFormBean
>>> Set org.apache.struts.action.ActionFormBean properties
>>> Begin event threw exception
>>> java.lang.IllegalArgumentException: object is not an instance of 
>>> declaring class
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42) 
>>>
>>> at 
>>> 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28) 
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:327)
>>> at 
>>> org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:988) 
>>>
>>> at 
>>> org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:904) 
>>>
>>> at 
>>> org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:932)
>>> at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:509)
>>> at 
>>> org.apache.struts.digester.SetPropertiesRule.begin(SetPropertiesRule.java:120) 
>>>
>>> at 
>>> org.apache.struts.digester.Digester.startElement(Digester.java:528)
>>> at 
>>> org.xml.sax.helpers.XMLReaderAdapter.startElement(XMLReaderAdapter.java:329) 
>>>
>>> at 
>>> org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
>>> at 
>>> 
>org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1214)
> 
>>>
>>> at 
>>> 
>org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
> 
>>>
>>> at 
>>> 
>org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1182)
> 
>>>
>>> at 
>>> 
>org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) 
>>>
>>> at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
>>> at 
>>> org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223)
>>> at javax.xml.parsers.SAXParser.parse(SAXParser.java:316)
>>> at javax.xml.parsers.SAXParser.parse(SAXParser.java:91)
>>> at org.apache.struts.digester.Digester.parse(Digester.java:755)
>>> at 
>>> org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1331) 
>>>
>>> at 
>>> org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
>>> at javax.servlet.GenericServlet.init(GenericServlet.java)
>>> at 
>>> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java)
>>> at 
>>> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java) 
>>>
>>> at 
>>> org.apache.catalina.core.StandardContext.start(StandardContext.java)
>>> at 
>>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java)
>>> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java)
>>> at org.apache.catalina.core.StandardHost.install(StandardHost.java)
>>> at 
>>> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java)
>>> at org.apache.ca

Re: struts-config.xml-Is there a tool to find errors in it?

2001-12-19 Thread Tuomo Syvänperä

Hi Antony,
Are you using Sun's JDK 1.4 beta.. I got the same 'object is not an 
instance of declaring class' - error when I used JDK 1.4.
Try switching to 1.3

/tuomo

[EMAIL PROTECTED] wrote:

> Here is the part of the debug log which shows the error
> 
> ---start tomcat log--
> [snip]
> resolveEntity('-//Apache Software Foundation//DTD Struts Configuration 
> 1.0//EN', 'http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd')
>  Resolving to alternate DTD 
> 
>'jar:file:/var/tomcat4/webapps/sturdy/WEB-INF/lib/struts.jar!/org/apache/struts/resources/struts-config_1_0.dtd'
> 
> 
> New org.apache.struts.action.ActionFormBean
> Set org.apache.struts.action.ActionFormBean properties
> Begin event threw exception
> java.lang.IllegalArgumentException: object is not an instance of 
> declaring class
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42) 
> 
> at 
> 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28) 
> 
> at java.lang.reflect.Method.invoke(Method.java:327)
> at 
> org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:988) 
> 
> at 
> org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:904) 
> 
> at 
> org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:932)
> at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:509)
> at 
> org.apache.struts.digester.SetPropertiesRule.begin(SetPropertiesRule.java:120) 
> 
> at org.apache.struts.digester.Digester.startElement(Digester.java:528)
> at 
> org.xml.sax.helpers.XMLReaderAdapter.startElement(XMLReaderAdapter.java:329) 
> 
> at 
> org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
> at 
> 
>org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1214)
> 
> 
> at 
> 
>org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
> 
> 
> at 
> 
>org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1182)
> 
> 
> at 
> 
>org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) 
> 
> at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
> at 
> org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:316)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:91)
> at org.apache.struts.digester.Digester.parse(Digester.java:755)
> at 
> org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1331)
> at org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
> at javax.servlet.GenericServlet.init(GenericServlet.java)
> at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java)
> at 
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java) 
> 
> at org.apache.catalina.core.StandardContext.start(StandardContext.java)
> at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java)
> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java)
> at org.apache.catalina.core.StandardHost.install(StandardHost.java)
> at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java)
> at org.apache.catalina.startup.HostConfig.start(HostConfig.java)
> at 
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java)
> at 
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java) 
> 
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java)
> at org.apache.catalina.core.StandardService.start(StandardService.java)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java)
> at org.apache.catalina.startup.Catalina.start(Catalina.java)
> at org.apache.catalina.startup.Catalina.execute(Catalina.java)
> at org.apache.catalina.startup.Catalina.process(Catalina.java)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42) 
> 
> at 
> 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28) 
> 
> at java.lang.reflect.Method.invoke(Method.java:327)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java)
> Starting service Tomcat-Apache
> Apache Tomcat/4.0.1
> -end tomcat log--
> 
> 
> 
> 
> Jeff Martin wrote:
> 
>> What kind of error do you mean? Does it parse and validate against the 
>> provided DTD?
>>
>

My implementation of Action chaining - Fixed

2001-12-14 Thread Tuomo Syvänperä

Sorry.. I forgot one method from the ActionBase - class..
Attached is the new version.

/tuomo


Page A:
- has the following  tag


- if there is access to page B from some other page C we should also add the
  tag to page C otherwise there is the possibility that we would return
  to page A accidentally


// 

//
// ActionBase class. Handles all redirects required by ReturnStamp
//
class ActionBase extends Action {
  //
  // ...
  //
  public final ActionForward perform( ActionMapping mapping, ActionForm form,
  HttpServletRequest request, HttpServletResponse response )
  throws IOException, ServletException {

// NOTE: we first have to call the doPerform - method so that after
//   we get the stamp from the session and store it in the request,
//   it doesn't mess up this actions request processing
ActionForward forward = doPerform( mapping, form, request, response );

// Check for possible return stamps
HttpSession session   = request.getSession();
ReturnStamps stamps   = (ReturnStamps)session.getAttribute( 
Constants.RETURN_STAMPS_KEY );
ActionForward stampForward = null;

if( stamps != null ) {
  ReturnStamp stamp = stamps.findStamp( request.getServletPath());
  if( stamp != null ) {
stampForward = new ActionForward( stamp.getTo());

// Remove this stamp from the session and store it in the request
stamps.removeStamp( stamp );
session.setAttribute( Constants.RETURN_STAMPS_KEY, stamps );
request.setAttribute( Constants.RETURN_STAMP_KEY, stamp );
  }
}
if( stampForward != null ) return stampForward;

return forward;
  }

  // All implementing classes should call this method to retrieve
  // parameters or attributes from the request
  public Object getParabute( String parabuteName, HttpServletRequest request ) {
Object obj = null;

ReturnStamp stamp = (ReturnStamp)request.getAttribute( Constants.RETURN_STAMP_KEY 
);

if( stamp != null ) {
  if( (obj = stamp.getAttribute( parabuteName )) != null ) {
stdOutLog( "getParabute() called. ", 2 );
stdOutLog( "  parabute fround in return stamp.", 2, false );
return obj;
  }
}

if( (obj = request.getAttribute( parabuteName )) == null ) {
  obj = request.getParameter( parabuteName );
  stdOutLog( "getParabute() called. ", 2 );
  stdOutLog( "  parabute fround in request parameters.", 2, false );
} else {
  stdOutLog( "getParabute() called. ", 2 );
  stdOutLog( "  parabute fround in request attributes.", 2, false );
}

return obj;
  }
}

// 

//
// ReturnStampTag implementation
//
import java.util.Enumeration;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import common.Constants;
import common.ReturnStamp;
import common.ReturnStamps;

public final class ReturnStampTag extends TagSupport {
  protected String to   = null;
  protected String from = null;

  public String getTo() {
return to;
  }

  public void setTo( String to ) {
this.to = to;
  }

  public String getFrom() {
return from;
  }

  public void setFrom( String from ) {
this.from = from;
  }

  public int doStartTag() throws JspException {
return SKIP_BODY;
  }

  public int doEndTag() throws JspException {
HttpSession session = pageContext.getSession();

if( session == null ) {
  return EVAL_PAGE;
}

ServletRequest request = pageContext.getRequest();

ReturnStamps stamps = (ReturnStamps)session.getAttribute( 
Constants.RETURN_STAMPS_KEY );

if( stamps == null ) {
  stamps = new ReturnStamps();
}

ReturnStamp stamp  = new ReturnStamp( getTo(), getFrom());

for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
  String name = (String)e.nextElement();
  if( name != null ) {
stamp.addAttribute( name, request.getParameter( name ));
  }
}

for( Enumeration e = request.getAttributeNames(); e.hasMoreElements(); ) {
  String name = (String)e.nextElement();
  if( name != null ) {
stamp.addAttribute( name, request.getAttribute( name ));
  }
}

stamps.removeStamp( stamp );
stamps.addStamp( stamp );

session.setAttribute( Constants.RETURN_STAMPS_KEY, stamps );

return EVAL_PAGE;
  }
}

// 

//
// ReturnStamps implementation
//
import java.util.HashMap;
import java.io.Serializable;

public class ReturnStamp implements Serializable {
  protected String  to = null;
  protected String  from   = null;
  protected HashMap attributes = new HashMap();

  public ReturnStamp() {
  }

  public ReturnStamp( String to, String from ) {
 

My implementation of Action chaining...

2001-12-14 Thread Tuomo Syvänperä

Hi..
I posted earlier my suggestion to the action chaining problem...
Well, here's a bare-bones implementation of what I was talking about.
Again, this may be totally f*cked up but it's your job to tell me
what I'm doing wrong :)
I've attached my (partial) implementation to this post..

/tuomo


Page A:
- has the following  tag


- if there is access to page B from some other page C we should also add the
  tag to page C otherwise there is the possibility that we would return
  to page A accidentally


// 

//
// ActionBase class. Handles all redirects required by ReturnStamp
//
class ActionBase extends Action {
  //
  // 
  //
  public final ActionForward perform( ActionMapping mapping, ActionForm form,
  HttpServletRequest request, HttpServletResponse response )
  throws IOException, ServletException {

// NOTE: we first have to call the doPerform - method so that after
//   we get the stamp from the session and store it in the request,
//   it doesn't mess up this actions request processing
ActionForward forward = doPerform( mapping, form, request, response );

// Check for possible return stamps
HttpSession session   = request.getSession();
ReturnStamps stamps   = (ReturnStamps)session.getAttribute( 
Constants.RETURN_STAMPS_KEY );
ActionForward stampForward = null;

if( stamps != null ) {
  ReturnStamp stamp = stamps.findStamp( request.getServletPath());
  if( stamp != null ) {
stampForward = new ActionForward( stamp.getTo());

// Remove this stamp from the session and store it in the request
stamps.removeStamp( stamp );
session.setAttribute( Constants.RETURN_STAMPS_KEY, stamps );
request.setAttribute( Constants.RETURN_STAMP_KEY, stamp );
  }
}
if( stampForward != null ) return stampForward;

return forward;
  }
}

// 

//
// ReturnStampTag implementation
//
import java.util.Enumeration;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import common.Constants;
import common.ReturnStamp;
import common.ReturnStamps;

public final class ReturnStampTag extends TagSupport {
  protected String to   = null;
  protected String from = null;

  public String getTo() {
return to;
  }

  public void setTo( String to ) {
this.to = to;
  }

  public String getFrom() {
return from;
  }

  public void setFrom( String from ) {
this.from = from;
  }

  public int doStartTag() throws JspException {
return SKIP_BODY;
  }

  public int doEndTag() throws JspException {
HttpSession session = pageContext.getSession();

if( session == null ) {
  return EVAL_PAGE;
}

ServletRequest request = pageContext.getRequest();

ReturnStamps stamps = (ReturnStamps)session.getAttribute( 
Constants.RETURN_STAMPS_KEY );

if( stamps == null ) {
  stamps = new ReturnStamps();
}

ReturnStamp stamp  = new ReturnStamp( getTo(), getFrom());

for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
  String name = (String)e.nextElement();
  if( name != null ) {
stamp.addAttribute( name, request.getParameter( name ));
  }
}

for( Enumeration e = request.getAttributeNames(); e.hasMoreElements(); ) {
  String name = (String)e.nextElement();
  if( name != null ) {
stamp.addAttribute( name, request.getAttribute( name ));
  }
}

stamps.removeStamp( stamp );
stamps.addStamp( stamp );

session.setAttribute( Constants.RETURN_STAMPS_KEY, stamps );

return EVAL_PAGE;
  }
}

// 

//
// ReturnStamps implementation
//
import java.util.HashMap;
import java.io.Serializable;

public class ReturnStamp implements Serializable {
  protected String  to = null;
  protected String  from   = null;
  protected HashMap attributes = new HashMap();

  public ReturnStamp() {
  }

  public ReturnStamp( String to, String from ) {
this.to   = to;
this.from = from;
  }

  public String getTo() {
return to;
  }

  public void setTo( String to ) {
this.to = to;
  }

  public String getFrom() {
return from;
  }

  public void setFrom( String from ) {
this.from = from;
  }

  public Object getAttribute( String name ) {
return attributes.get( name );
  }

  public void addAttribute( String name, Object obj ) {
attributes.put( name, obj );
  }
}

// 

//
// ReturnStamps implementation
//
import java.util.HashMap;
import java.io.Serializable;

public class ReturnStamps implements Serializable {
  protected HashMap stamps = new HashMap();

  public void addStamp( ReturnSt

Chaining actions etc...

2001-12-14 Thread Tuomo Syvänperä

Hi,
There's been loads of discussion about how to implement this action 
chaining..
Last night I cooked up yet another possible way to do it..
The chainToPage class implementation by Keith Bacon posted earlier 
seemed like a nice way to do it at first.. But what I'm looking for is
a more generic way to do this without the action classes actually even
realizing what's happening..
I have a semi-working implementation of the following:

- On the page to which we want to chain to another page we add the
   following tag on the jsp-page (or something similar).
   
- the returnStamp tag saves request parameters and attributes into
   an object (let's call it a stampObject) that is stored to the
   session along with the to and from information
- all action - classes are extended from some baseaction (as suggested
   by Ted Husted) and this baseaction checks the session to see if there
   is a stampObject in the session with a from field for this action.
- if there is one, a new ActionForward object is constructed from
   the to - field and this page forwards to it after the processing is
   done
- when we return to /thisAction we extract the attributes from
   the stampObject and store them as request attributes and remove
   the stampObject from the session.

Now to achieve the transparency we should define a few helper methods
to our baseaction - class.
- getParabute( HttpServletRequest request, String name )
   * perform calls this to acquire both request parameters and
 attributes because if we were forwarded from another action the
 needed parameters for this action are not stored in the request
 parameters but in the attributes. This method first tries to
 find the requested 'name' parameter from attributes and then from
 parameters

Possible quirks:
- If we never get back to the /thisAction - page we never remove the
   stampObject from the session. I'm not sure how much stuff we should
   store in the session.. This is actually one question that someone
   could answer: How much stuff should you save in the session and are
   there any reasons why _not_ to store long term data in the session ?
- If we have the following page structure:
   page A -> page B -> page C -> (back to) page A
   Now from page C we return to page A by using the method described
   above. But what if we have a page D that the user can get to from
   page B and the user goes there and later from page D the user
   goes back to page B and from there should be forwarded back to page D.
   But in the session we have another forward for this page
   (the original one. Going back to page A) and we return there and
   _not_ to page D.
   * The only solution to this problem I have come up so far is to
 add the  - tag to _all_ pages that
 we can get to from page C

Hopefully my explanation was clear enough..
Now your task, should you choose to accept it, is to shoot down this idea :)

/tuomo


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




Re: ActionMappings parameter - field

2001-12-13 Thread Tuomo Syvänperä

Thx..
But is it safe to use setParameter in your own actions and if I do 
should i enclose it in a synchronized block ?

/tuomo

Jon.Ridgway wrote:

> Hi Tuomo,
> 
> The mapping parameter is an arbitrary string associated with a mapping that
> can be accessed via mapping.getParameter ().
> 
> Jon.
> 
> -Original Message-
> From: Tuomo Syvänperä [mailto:[EMAIL PROTECTED]] 
> Sent: 13 December 2001 12:45
> To: [EMAIL PROTECTED]
> Subject: ActionMappings parameter - field
> 
> Hi,
> What is the parameter - field for in the ActionMapping class ?
> I was thinking about storing some info there that I use to communicate
> some things between my actions. Is it safe to just call 
> ActionMapping.setParameter and set its value or should it be put inside 
> a synchronized block ?
> 
> /tuomo
> 
> 
> --
> 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]>




ActionMappings parameter - field

2001-12-13 Thread Tuomo Syvänperä

Hi,
What is the parameter - field for in the ActionMapping class ?
I was thinking about storing some info there that I use to communicate
some things between my actions. Is it safe to just call 
ActionMapping.setParameter and set its value or should it be put inside 
a synchronized block ?

/tuomo


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




Re: Alternate form action - corrected!

2001-12-12 Thread Tuomo Syvänperä

Hi..
Makes sense actually.. Not sure if we have to go so deep as to add new 
configuration
fields. Maybe just extending one of the main controller modules..
ActionServlet, Action, ActionForward, ActionMapping etc.
Gotta look into that..
But one possible problem:
1. the user is on a page with a list of articles
2. user clicks view article
3. on the view article page he clicks edit
*now the edit page is a page which shows a form and it is used from
  view article and list articles pages. So, the view article action puts
  a ChainToPage object into the session so that after the form is
  processed we now were we should return.
4. on the edit form there is a link back to the article list and the
user clicks that and doesn't submit the edit form (or the user
hits back - button a couple of times)
5. now on the article list page the user clicks edit straight from
one of the article titles or something.. Anyway he goes back to
the edit page and submits the form..
6. the user is back on the view article page and not the list articles page.

Am I totally lost here :)

/tuomo

2. User comes to the page which should read

Keith Bacon wrote:

>Hi Tuomo
>I'm about to work on that now. I'm thinking of setting
>up a ChainToPage class in the session. This would have
>properties 
> // The global forwards to forward to
>   String forwardTo
>
> // Name of Action this was set up for.
>   String forUseBy 
>
> // parms eg.  selectedListItems,
> //selectedMultiBoxItem
> //sortSequece
> //position in Page to return to
>   HashMap attributes
>A page can set up one of these objects & forward to a
>'slave' page - ie. a page that on completion forwards
>to the forwardTo page. This would then work for
>returning to an invoking page & also for chaining.
>
>Problems:-
>1 - People say using session doesn't scale. Personally
>I think it has to be made to! It's the logical place
>to save data - it's up to the servers to provide
>performance.
>2 - Junk gets left around by pgm errors or after
>exceptions. Careful hosekeeping needed. If only 1 such
>object can exist it's easier. Multiple levels of this
>would need some serious code.
>Keith.
>===
>PS. Some more:-
>Maybe struts could be enhanced to support this (not
>sure how yet!) but something like in config file 
>for linkList action definition instead of the usual
>forward definition
>
>
>
>have this
>path="/linkMaint.do"
>returnParms="mypackage.LinkListReturnParms"/>
>
>returnParms="mypackage.LinkListReturnParms"/>
>
>ie. this page may forward to LinkMaint or to logon &
>those pages will return to linkList on completion.
>struts would pass mypackage.LinkListReturnParms to the
>linkList Action class which would fill them in. If the
>linklist uses forwardAndReturn struts will keep those
>parms in the session until linkList is re-invoked.
>Make sense?
>
>Keith
>
>
>
>
>
>
>
>
>--- Tuomo Syvänperä <[EMAIL PROTECTED]>
>wrote:
>
>>In a way this is exactly what I do right now.. But
>>the problem is the 
>>request attributes & parameters sent to the
>>'returnTo' page.. These are 
>>lost when using this technique..
>>In my version I also set the request attributes as
>>hidden form fields 
>>and pass them
>>on like that.. But I wasn't sure if it's a good idea
>>to pass them on as 
>>hidden fields..
>>
>>/tuomo
>>
>>Keith Bacon wrote:
>>
>>>--- Keith Bacon <[EMAIL PROTECTED]> wrote:
>>>
>>>>Tuomo,
>>>>Not totally finalised but at the moment I do it a
>>>>bit
>>>>like the example below.
>>>>If you searched the archives for 'logon page'
>>>>
>>there
>>
>>>>are ways you can forward to the logon page & have
>>>>
>>it
>>
>>>>return to the page that started it, which is the
>>>>same
>>>>thing. These example are probably better than
>>>>
>>mine!
>>
>>>>Keith.
>>>>==
>>>>example - form1 transfers to form2 & wants form2
>>>>
>>to
>>
>>>>transfer to form1.
>>>>
>>>>
>>>>form1 has
>>>>/*
>>>>* Let next form know where to return to.
>>>>*/
>>>>request.addAttribute("returnTo",
>>>>"globalForwardForm1");
>>>>
>>>>
>>>>form2 has
>>>>/*--

Re: Alternate form action - corrected!

2001-12-12 Thread Tuomo Syvänperä

In a way this is exactly what I do right now.. But the problem is the 
request attributes & parameters sent to the 'returnTo' page.. These are 
lost when using this technique..
In my version I also set the request attributes as hidden form fields 
and pass them
on like that.. But I wasn't sure if it's a good idea to pass them on as 
hidden fields..

/tuomo

Keith Bacon wrote:

>--- Keith Bacon <[EMAIL PROTECTED]> wrote:
>
>>Tuomo,
>>Not totally finalised but at the moment I do it a
>>bit
>>like the example below.
>>If you searched the archives for 'logon page' there
>>are ways you can forward to the logon page & have it
>>return to the page that started it, which is the
>>same
>>thing. These example are probably better than mine!
>>Keith.
>>==
>>example - form1 transfers to form2 & wants form2 to
>>transfer to form1.
>>
>>
>>form1 has
>>/*
>>* Let next form know where to return to.
>>*/
>>request.addAttribute("returnTo",
>>"globalForwardForm1");
>>
>>
>>form2 has
>>/*
>>1 - save the input returnTo value. 1st time in
>>caller
>>has stored it as req. attribute. Subsequent times
>>this
>>action has saved it as a hidden field on the form
>>(could save in the session).
>>--*/
>>String returnTo = request.getAttribute("returnTo");
>>if (returnTo == null) formBean.getReturnTo();
>>
>>thisForm.setReturnTo() = returnTo;
>>
>>/*
>>* 2 - on completion
>>*/
>>return new ActionForward("returnTo");
>>
>>
>>
>>
>>
>>
>>--- Tuomo Syvänperä <[EMAIL PROTECTED]>
>>wrote:
>>
>>>Hmm.. Nope. mapping.getInput() always returns the
>>>same thing regardless 
>>>of the
>>>page from which we came from.
>>>Here's a bit more detailed explanation of what's
>>>going on:
>>>
>>>I have a page (action: listArticles.do) which
>>>
>>lists
>>
>>>all articles. On 
>>>this page if you
>>>click on the edit - link,
>>>editArticle.do?action=Edit&id=123 action gets 
>>>called.
>>>This action redirects the user to the
>>>editArticle.jsp page which has the 
>>>edit form in it.
>>>Now if the user clicks on the title of the article
>>>on listArticles.do page,
>>>viewArticle.do?id=123 action gets called and shows
>>>the article. On this 
>>>page we
>>>allso have an edit - link, which has the same url
>>>
>>as
>>
>>>the one on 
>>>listArticles - page.
>>>
>>>The form submits its contents to saveArticle.do -
>>>action which does just 
>>>that.. Saves
>>>the article using an EJB. After the save we should
>>>return to the calling 
>>>page but at
>>>this point we no longer know which page was the
>>>original caller. And 
>>>even if we did,
>>>we'd have no way of returning the request to the
>>>same state as it was 
>>>before the
>>>editArticle - link was pressed (ie. the
>>>
>>viewArticle
>>
>>>had the article id 
>>>as a parameter and
>>>if we forward control back to that viewArticle
>>>action, we really should 
>>>have the id also).
>>>
>>>Now in saveArticle - action mapping.getInput()
>>>returns the 
>>>editArticle.jsp form and
>>>not the page from which we came from..
>>>
>>>/tuomo
>>>
>>>Jon.Ridgway wrote:
>>>
>>>>Hi Tuomo,
>>>>
>>>>You could try using:
>>>>
>>>>mapping.getInput ()
>>>>
>>>>in your actions perform method.
>>>>
>>>>Jon.
>>>>
>>>>-Original Message-
>>>>From: Tuomo Syvänperä
>>>>
>>>[mailto:[EMAIL PROTECTED]] 
>>>
>>>>Sent: 12 December 2001 09:47
>>>>To: [EMAIL PROTECTED]
>>>>Subject: Alternate form action
>>>>
>>>>Hi,
>>>>How can I return to correct page after submitting
>>>>
>>a
>>
>>>form which can be 
>>>
>>>>called from
>>>>several places..
>>>>What I have is a action&form which can be
>>>>
>>accessed
>>
>>>from many different 
>>>
>>>>places.
>>>>ie. I have page A with a link:
&

Re: Alternate form action

2001-12-12 Thread Tuomo Syvänperä

Hmm.. Nope. mapping.getInput() always returns the same thing regardless 
of the
page from which we came from.
Here's a bit more detailed explanation of what's going on:

I have a page (action: listArticles.do) which lists all articles. On 
this page if you
click on the edit - link, editArticle.do?action=Edit&id=123 action gets 
called.
This action redirects the user to the editArticle.jsp page which has the 
edit form in it.
Now if the user clicks on the title of the article on listArticles.do page,
viewArticle.do?id=123 action gets called and shows the article. On this 
page we
allso have an edit - link, which has the same url as the one on 
listArticles - page.

The form submits its contents to saveArticle.do - action which does just 
that.. Saves
the article using an EJB. After the save we should return to the calling 
page but at
this point we no longer know which page was the original caller. And 
even if we did,
we'd have no way of returning the request to the same state as it was 
before the
editArticle - link was pressed (ie. the viewArticle had the article id 
as a parameter and
if we forward control back to that viewArticle action, we really should 
have the id also).

Now in saveArticle - action mapping.getInput() returns the 
editArticle.jsp form and
not the page from which we came from..

/tuomo

Jon.Ridgway wrote:

>Hi Tuomo,
>
>You could try using:
>
>   mapping.getInput ()
>
>in your actions perform method.
>
>Jon.
>
>-Original Message-
>From: Tuomo Syvänperä [mailto:[EMAIL PROTECTED]] 
>Sent: 12 December 2001 09:47
>To: [EMAIL PROTECTED]
>Subject: Alternate form action
>
>Hi,
>How can I return to correct page after submitting a form which can be 
>called from
>several places..
>What I have is a action&form which can be accessed from many different 
>places.
>ie. I have page A with a link:
>paramName="article" paramProperty="id">key="global.edit"/>
>and page B with the same link. When the user posts the form, I'd like to 
>return to
>the page from which we came from.
>Problem is that I cannot tell what possible request parameters or 
>attributes the original
>page had gotten before the call to editArticle.
>
>Currently only solution I came up with was to set attributes to servlet 
>context, which
>contain the page to which we should return and all it's request 
>parameters. And then when
>I populate the editArticle form, I add all these attributes as hidden 
>fields to the form.
>After the form has been submitted the SaveArticleAction saves the form 
>data and
>redirects back to the original calling page..
>
>I hope my explanation was unclear enough :)
>
>Thx.
>Tuomo
>
>
>
>--
>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: Alternate form action

2001-12-12 Thread Tuomo Syvänperä

Hmm.. Nope. mapping.getInput() always returns the same thing regardless 
of the
page from which we came from.
Here's a bit more detailed explanation of what's going on:

I have a page (action: listArticles.do) which lists all articles. On 
this page if you
click on the edit - link, editArticle.do?action=Edit&id=123 action gets 
called.
This action redirects the user to the editArticle.jsp page which has the 
edit form in it.
Now if the user clicks on the title of the article on listArticles.do page,
viewArticle.do?id=123 action gets called and shows the article. On this 
page we
allso have an edit - link, which has the same url as the one on 
listArticles - page.

The form submits its contents to saveArticle.do - action which does just 
that.. Saves
the article using an EJB. After the save we should return to the calling 
page but at
this point we no longer know which page was the original caller. And 
even if we did,
we'd have no way of returning the request to the same state as it was 
before the
editArticle - link was pressed (ie. the viewArticle had the article id 
as a parameter and
if we forward control back to that viewArticle action, we really should 
have the id also).

Now in saveArticle - action mapping.getInput() returns the 
editArticle.jsp form and
not the page from which we came from..

/tuomo

Jon.Ridgway wrote:

>Hi Tuomo,
>
>You could try using:
>
>   mapping.getInput ()
>
>in your actions perform method.
>
>Jon.
>
>-Original Message-
>From: Tuomo Syvänperä [mailto:[EMAIL PROTECTED]] 
>Sent: 12 December 2001 09:47
>To: [EMAIL PROTECTED]
>Subject: Alternate form action
>
>Hi,
>How can I return to correct page after submitting a form which can be 
>called from
>several places..
>What I have is a action&form which can be accessed from many different 
>places.
>ie. I have page A with a link:
>paramName="article" paramProperty="id">key="global.edit"/>
>and page B with the same link. When the user posts the form, I'd like to 
>return to
>the page from which we came from.
>Problem is that I cannot tell what possible request parameters or 
>attributes the original
>page had gotten before the call to editArticle.
>
>Currently only solution I came up with was to set attributes to servlet 
>context, which
>contain the page to which we should return and all it's request 
>parameters. And then when
>I populate the editArticle form, I add all these attributes as hidden 
>fields to the form.
>After the form has been submitted the SaveArticleAction saves the form 
>data and
>redirects back to the original calling page..
>
>I hope my explanation was unclear enough :)
>
>Thx.
>Tuomo
>
>
>
>--
>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]>




Alternate form action

2001-12-12 Thread Tuomo Syvänperä

Hi,
How can I return to correct page after submitting a form which can be 
called from
several places..
What I have is a action&form which can be accessed from many different 
places.
ie. I have page A with a link:

and page B with the same link. When the user posts the form, I'd like to 
return to
the page from which we came from.
Problem is that I cannot tell what possible request parameters or 
attributes the original
page had gotten before the call to editArticle.

Currently only solution I came up with was to set attributes to servlet 
context, which
contain the page to which we should return and all it's request 
parameters. And then when
I populate the editArticle form, I add all these attributes as hidden 
fields to the form.
After the form has been submitted the SaveArticleAction saves the form 
data and
redirects back to the original calling page..

I hope my explanation was unclear enough :)

Thx.
Tuomo



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