You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Debasish Ghosh <gh...@yahoo.com> on 2001/09/02 19:58:06 UTC

Dynamic Forwarding ...

Hi All -

I have trying to implement dynamic forwarding in my
application.
In the Action class where I am preparing the forward
URL, I am doing the following :

ActionForward fwd = mapping.findForward("dummy");
StringBuffer path = new StringBuffer( fwd.getPath() );
path.append( "?formName=" ).append( action );
return new ActionForward( path.toString(), 
                          fwd.getRedirect() );

With this, I am getting the correct parameter to
ActionForward, and the control is also forwarded to
the appropriate JSP. But I am not able to access the
passed-in parameter. I have a property named
"formName" in the called form. But from the action of
the called form, when I access the property
getFormName(), I get NULL.

In order to achieve this, do I have to declare
anything in the JSP ?

Please help !!

Regards.

- Debasish


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Re: Dynamic Forwarding ...

Posted by Troy Hart <th...@part.net>.
Instead of trying to add a parameter to the forward, it sounds like you would 
be better served to simply add a request attribute to specify the "formName". 
In your action class you do this:

request.setAttribute("formName", action);

Then on your jsp page:

<html:hidden name="formName" />

That should do it.

Troy

On Monday 03 September 2001 03:34 am, you wrote:
> Thanks, Ted, for the reply.
> Actually, I am not forwarding from Action to Action.
> The mapping of the forward "dummy" resolves to a JSP
> named dummy.jsp and not an action (*.do).
>
> From an action, on submit, I would like to tansfer
> control to a JSP to accept more inputs. Along with
> this control transfer, I would like to pass a
> parameter to indicate some logic.
>
> I finally did this using a request.getParameter(
> "formName" ) in the JSP as a scriplet, and declaring a
> hidden property in the JSP :
> <html:hidden property="formName" value="<%= formName
> %>" />
>
> Now I can access this property from the action class
> of the form dummyForm. Please suggest, if there is a
> better method of doing this (without the scriplet).
>
> Regarding the link that u have mentioned, I had
> already gone thru it. I do not understand one point.
> If I have a form formA, having a property "formName",
> then when I forward to another form, formB, how will
> the property be retained as part of formB ?
>
> Regards.
>
> - Debasish
>
> --- Ted Husted <hu...@apache.org> wrote:
> > What's in the JSP wouldn't matter, since you are
> > going from one Action
> > to another.
> >
> > If formName is a property in the ActionForm, then it
> > shuld be populated.
> >
> > I would try using request.getParameter("formName")
> > and see if that's
> > null too.
> >
> > I'd also try hardcoding the value for action to be
> > sure that is not
> > null.
> >
> > If you haven't already, see also
>
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg14280.html
>
> > Debasish Ghosh wrote:
> > > Hi All -
> > >
> > > I have trying to implement dynamic forwarding in
> >
> > my
> >
> > > application.
> > > In the Action class where I am preparing the
> >
> > forward
> >
> > > URL, I am doing the following :
> > >
> > > ActionForward fwd = mapping.findForward("dummy");
> > > StringBuffer path = new StringBuffer(
> >
> > fwd.getPath() );
> >
> > > path.append( "?formName=" ).append( action );
> > > return new ActionForward( path.toString(),
> > >                           fwd.getRedirect() );
> > >
> > > With this, I am getting the correct parameter to
> > > ActionForward, and the control is also forwarded
> >
> > to
> >
> > > the appropriate JSP. But I am not able to access
> >
> > the
> >
> > > passed-in parameter. I have a property named
> > > "formName" in the called form. But from the action
> >
> > of
> >
> > > the called form, when I access the property
> > > getFormName(), I get NULL.
> > >
> > > In order to achieve this, do I have to declare
> > > anything in the JSP ?
> > >
> > > Please help !!
> > >
> > > Regards.
> > >
> > > - Debasish
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get email alerts & NEW webcam video instant
> >
> > messaging with Yahoo! Messenger
> >
> > > http://im.yahoo.com
>
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com

iterating over trees

Posted by Andreas Leitner <al...@macron.at>.
Dear list,

given that I have a JavaBean Strutcture that exposes a tree of some
form. Each node contains a String and any number of children. I would
like to render such a Bean into a site-map like html page via jsp code.

The interesting part, though, would be a tree-pendant to
<logic:iterate>. What I have in mind is s.th. like this


<logic:treeIterate bean="nameOfMyBean" type="string">
	<preStepDown>
		<ul>
	</preStepDown>
	<item>
		<li>
		... output the name of the node ... (via bean:write for
example)
		</li>
	</item>
	<postStepDown>
		</ul>
	</postStepDown>
</logic:treeIterate>

Which would give as output something like this (rendered by:
aleitner-is-not-lynx-v-0.0.1):

* Item 1
	* Item 1.1
	* Item 1.2
* Item 2
* Item 3
	* Item 3.1
	* Item 3.2
		* Item 3.2.1
		* Item 3.2.2

(generated html-source)
<ul>
	<li> Item 1 </li>
	<ul>
		<li>Item 1.1</li>
		<li>Item 1.2</li>
	</ul>
	<li> Item 2 </li>
	<li> Item 3 </li>
	<ul>
		<li> Item 3.1 </li>
		<li> Item 3.2 </li>
		<ul>
			<li> Item 3.2.1 </li>
			<li> Item 3.2.2 </li>
		</ul>
	</ul>
</ul>

		

given the right tree-bean of course (;

Now my question, does such a tag-lib exists? I have implemented a few
simple highly specialized beans for the project I am working on, but I
have no idea how to write such nested and interdepended tags. If no such
libraries exist, can somebody give me some hints for how I should go for
implementing such a thing?

Many thanks in advance,
Andreas


Re: Dynamic Forwarding ...

Posted by Debasish Ghosh <gh...@yahoo.com>.
Thanks, Ted, for the reply. 
Actually, I am not forwarding from Action to Action.
The mapping of the forward "dummy" resolves to a JSP
named dummy.jsp and not an action (*.do). 

>From an action, on submit, I would like to tansfer
control to a JSP to accept more inputs. Along with
this control transfer, I would like to pass a
parameter to indicate some logic.

I finally did this using a request.getParameter(
"formName" ) in the JSP as a scriplet, and declaring a
hidden property in the JSP :
<html:hidden property="formName" value="<%= formName
%>" />

Now I can access this property from the action class
of the form dummyForm. Please suggest, if there is a
better method of doing this (without the scriplet).

Regarding the link that u have mentioned, I had
already gone thru it. I do not understand one point.
If I have a form formA, having a property "formName",
then when I forward to another form, formB, how will
the property be retained as part of formB ? 

Regards.

- Debasish


--- Ted Husted <hu...@apache.org> wrote:
> What's in the JSP wouldn't matter, since you are
> going from one Action
> to another. 
> 
> If formName is a property in the ActionForm, then it
> shuld be populated. 
> 
> I would try using request.getParameter("formName")
> and see if that's
> null too. 
> 
> I'd also try hardcoding the value for action to be
> sure that is not
> null. 
> 
> If you haven't already, see also 
> 
>
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg14280.html
> 
> 
> Debasish Ghosh wrote:
> > 
> > Hi All -
> > 
> > I have trying to implement dynamic forwarding in
> my
> > application.
> > In the Action class where I am preparing the
> forward
> > URL, I am doing the following :
> > 
> > ActionForward fwd = mapping.findForward("dummy");
> > StringBuffer path = new StringBuffer(
> fwd.getPath() );
> > path.append( "?formName=" ).append( action );
> > return new ActionForward( path.toString(),
> >                           fwd.getRedirect() );
> > 
> > With this, I am getting the correct parameter to
> > ActionForward, and the control is also forwarded
> to
> > the appropriate JSP. But I am not able to access
> the
> > passed-in parameter. I have a property named
> > "formName" in the called form. But from the action
> of
> > the called form, when I access the property
> > getFormName(), I get NULL.
> > 
> > In order to achieve this, do I have to declare
> > anything in the JSP ?
> > 
> > Please help !!
> > 
> > Regards.
> > 
> > - Debasish
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Get email alerts & NEW webcam video instant
> messaging with Yahoo! Messenger
> > http://im.yahoo.com


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Re: Dynamic Forwarding ...

Posted by Ted Husted <hu...@apache.org>.
What's in the JSP wouldn't matter, since you are going from one Action
to another. 

If formName is a property in the ActionForm, then it shuld be populated. 

I would try using request.getParameter("formName") and see if that's
null too. 

I'd also try hardcoding the value for action to be sure that is not
null. 

If you haven't already, see also 

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg14280.html


Debasish Ghosh wrote:
> 
> Hi All -
> 
> I have trying to implement dynamic forwarding in my
> application.
> In the Action class where I am preparing the forward
> URL, I am doing the following :
> 
> ActionForward fwd = mapping.findForward("dummy");
> StringBuffer path = new StringBuffer( fwd.getPath() );
> path.append( "?formName=" ).append( action );
> return new ActionForward( path.toString(),
>                           fwd.getRedirect() );
> 
> With this, I am getting the correct parameter to
> ActionForward, and the control is also forwarded to
> the appropriate JSP. But I am not able to access the
> passed-in parameter. I have a property named
> "formName" in the called form. But from the action of
> the called form, when I access the property
> getFormName(), I get NULL.
> 
> In order to achieve this, do I have to declare
> anything in the JSP ?
> 
> Please help !!
> 
> Regards.
> 
> - Debasish
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com