You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by marc <wd...@wilson.dk> on 2004/10/12 12:06:16 UTC
Mulitiple html:link but only one action
I have a jsp page with 3 html:link tags on it. I what all these links to
point to the same action, but each of them need to go to there own jsp
site. So I need to set/pass on a string with each link, so that I can
send the request the right place.
How do I do that??
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by Jeff Beal <jb...@webmedx.com>.
So, apparently I completely misunderstood the problem. I'll go back to
one of the HTML examples from one of my earlier posts:
<a href="view.do?display=page1">Text</a>
To get the value 'page1' from within your Action, all you need to do is
'request.getParameter("display")'. The corresponding html:link code
could be
<html:link action="view" paramId="display"
paramName="bean1">text</html:link>
where 'bean1' is the name of a bean whose String value is "page1".
Have a look at the JavaDoc for DispatchAction. You can create a
sub-class of DispatchAction with a method for each possible value of
your display attribute and DispatchAction will handle the rest.
-- Jeff
marc wrote:
> Yeah is't the Action code that I got problems with.
>
> Can't figure out have to read the html link in my action.
>
> Jeff Beal wrote:
>
>> Maybe, but I'm still not sure exactly where you're having problems.
>> Are you having problems writing the Action code to pass the request to
>> the different pages? If so, have a look at DispatchAction -- it is
>> one possible approach to this situation. If the problem is in using
>> the Struts tags to generate the appropriate HTML code to create a
>> link, then could you give an example of what code you want to generate
>> and we'll go from there?
>>
>> -- Jeff
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by marc <wd...@wilson.dk>.
Yeah is't the Action code that I got problems with.
Can't figure out have to read the html link in my action.
Jeff Beal wrote:
> Maybe, but I'm still not sure exactly where you're having problems. Are
> you having problems writing the Action code to pass the request to the
> different pages? If so, have a look at DispatchAction -- it is one
> possible approach to this situation. If the problem is in using the
> Struts tags to generate the appropriate HTML code to create a link, then
> could you give an example of what code you want to generate and we'll go
> from there?
>
> -- Jeff
>
> marc wrote:
>
>> I need af jsp page with 9 links on them. 3 link need to produceed 3
>> different lists. 3 needs to forward to 3 different forms. The last 3
>> need to point to 3 other jsp page.
>>
>> And i would like to use the same action for all 9 of them.
>>
>> Got at clearer picture of what I what?
>>
>>
>>
>> Jeff Beal wrote:
>>
>>> <html:link action="view"
>>> paramId="display"
>>> paramName="bean1">text</html:link>
>>>
>>> generates the same thing as
>>>
>>> <a href="view.do?display=<%=bean1%>">text</a>
>>>
>>> <html:link action="view"
>>> paramId="display"
>>> paramName="bean1"
>>> paramProperty="prop1">text</html:link
>>>
>>> generates the same thing as
>>>
>>> <a href="view.do?display=<%=bean1.getProp1()%>">text</a>
>>>
>>> <html:link action="view"
>>> name="map1">text</html:link>
>>>
>>> works similarly, but it loops through the map identified by the name
>>> 'map1' for the name/value pairs. It will generate something like:
>>>
>>> <a href="view.do?param1=value1¶m2=value2¶m3=value3">text</a>
>>>
>>> Using the page attribute instead of the action attribute may be more
>>> along the lines of what you want. I think
>>>
>>> <html:link page="view.do?display=page1">text</html:link>
>>>
>>> will display
>>>
>>> <a href="view.do?display=page1">text</a>
>>>
>>> But, I really don't know what you need, so all of these may be off
>>> the mark.
>>>
>>> -- Jeff
>>>
>>> marc wrote:
>>>
>>>> Have read that 1000 times, don't understand it(I now that it's
>>>> probely me how is a bit stupid)
>>>>
>>>> Can you give me a and example on have it works, and have I read the
>>>> string in my action class again.
>>>>
>>>> Thanks
>>>>
>>>> Jeff Beal wrote:
>>>>
>>>>> marc wrote:
>>>>>
>>>>>> I have a jsp page with 3 html:link tags on it. I what all these
>>>>>> links to point to the same action, but each of them need to go to
>>>>>> there own jsp site. So I need to set/pass on a string with each
>>>>>> link, so that I can send the request the right place.
>>>>>>
>>>>>> How do I do that??
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> This is explained in pretty good detail at
>>>>> http://struts.apache.org/userGuide/struts-html.html#link
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by Jeff Beal <jb...@webmedx.com>.
Maybe, but I'm still not sure exactly where you're having problems. Are
you having problems writing the Action code to pass the request to the
different pages? If so, have a look at DispatchAction -- it is one
possible approach to this situation. If the problem is in using the
Struts tags to generate the appropriate HTML code to create a link, then
could you give an example of what code you want to generate and we'll go
from there?
-- Jeff
marc wrote:
> I need af jsp page with 9 links on them. 3 link need to produceed 3
> different lists. 3 needs to forward to 3 different forms. The last 3
> need to point to 3 other jsp page.
>
> And i would like to use the same action for all 9 of them.
>
> Got at clearer picture of what I what?
>
>
>
> Jeff Beal wrote:
>
>> <html:link action="view"
>> paramId="display"
>> paramName="bean1">text</html:link>
>>
>> generates the same thing as
>>
>> <a href="view.do?display=<%=bean1%>">text</a>
>>
>> <html:link action="view"
>> paramId="display"
>> paramName="bean1"
>> paramProperty="prop1">text</html:link
>>
>> generates the same thing as
>>
>> <a href="view.do?display=<%=bean1.getProp1()%>">text</a>
>>
>> <html:link action="view"
>> name="map1">text</html:link>
>>
>> works similarly, but it loops through the map identified by the name
>> 'map1' for the name/value pairs. It will generate something like:
>>
>> <a href="view.do?param1=value1¶m2=value2¶m3=value3">text</a>
>>
>> Using the page attribute instead of the action attribute may be more
>> along the lines of what you want. I think
>>
>> <html:link page="view.do?display=page1">text</html:link>
>>
>> will display
>>
>> <a href="view.do?display=page1">text</a>
>>
>> But, I really don't know what you need, so all of these may be off the
>> mark.
>>
>> -- Jeff
>>
>> marc wrote:
>>
>>> Have read that 1000 times, don't understand it(I now that it's
>>> probely me how is a bit stupid)
>>>
>>> Can you give me a and example on have it works, and have I read the
>>> string in my action class again.
>>>
>>> Thanks
>>>
>>> Jeff Beal wrote:
>>>
>>>> marc wrote:
>>>>
>>>>> I have a jsp page with 3 html:link tags on it. I what all these
>>>>> links to point to the same action, but each of them need to go to
>>>>> there own jsp site. So I need to set/pass on a string with each
>>>>> link, so that I can send the request the right place.
>>>>>
>>>>> How do I do that??
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> This is explained in pretty good detail at
>>>> http://struts.apache.org/userGuide/struts-html.html#link
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by marc <wd...@wilson.dk>.
I need af jsp page with 9 links on them. 3 link need to produceed 3
different lists. 3 needs to forward to 3 different forms. The last 3
need to point to 3 other jsp page.
And i would like to use the same action for all 9 of them.
Got at clearer picture of what I what?
Jeff Beal wrote:
> <html:link action="view"
> paramId="display"
> paramName="bean1">text</html:link>
>
> generates the same thing as
>
> <a href="view.do?display=<%=bean1%>">text</a>
>
> <html:link action="view"
> paramId="display"
> paramName="bean1"
> paramProperty="prop1">text</html:link
>
> generates the same thing as
>
> <a href="view.do?display=<%=bean1.getProp1()%>">text</a>
>
> <html:link action="view"
> name="map1">text</html:link>
>
> works similarly, but it loops through the map identified by the name
> 'map1' for the name/value pairs. It will generate something like:
>
> <a href="view.do?param1=value1¶m2=value2¶m3=value3">text</a>
>
> Using the page attribute instead of the action attribute may be more
> along the lines of what you want. I think
>
> <html:link page="view.do?display=page1">text</html:link>
>
> will display
>
> <a href="view.do?display=page1">text</a>
>
> But, I really don't know what you need, so all of these may be off the
> mark.
>
> -- Jeff
>
> marc wrote:
>
>> Have read that 1000 times, don't understand it(I now that it's probely
>> me how is a bit stupid)
>>
>> Can you give me a and example on have it works, and have I read the
>> string in my action class again.
>>
>> Thanks
>>
>> Jeff Beal wrote:
>>
>>> marc wrote:
>>>
>>>> I have a jsp page with 3 html:link tags on it. I what all these
>>>> links to point to the same action, but each of them need to go to
>>>> there own jsp site. So I need to set/pass on a string with each
>>>> link, so that I can send the request the right place.
>>>>
>>>> How do I do that??
>>>
>>>
>>>
>>>
>>> This is explained in pretty good detail at
>>> http://struts.apache.org/userGuide/struts-html.html#link
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by Jeff Beal <jb...@webmedx.com>.
<html:link action="view"
paramId="display"
paramName="bean1">text</html:link>
generates the same thing as
<a href="view.do?display=<%=bean1%>">text</a>
<html:link action="view"
paramId="display"
paramName="bean1"
paramProperty="prop1">text</html:link
generates the same thing as
<a href="view.do?display=<%=bean1.getProp1()%>">text</a>
<html:link action="view"
name="map1">text</html:link>
works similarly, but it loops through the map identified by the name
'map1' for the name/value pairs. It will generate something like:
<a href="view.do?param1=value1¶m2=value2¶m3=value3">text</a>
Using the page attribute instead of the action attribute may be more
along the lines of what you want. I think
<html:link page="view.do?display=page1">text</html:link>
will display
<a href="view.do?display=page1">text</a>
But, I really don't know what you need, so all of these may be off the mark.
-- Jeff
marc wrote:
> Have read that 1000 times, don't understand it(I now that it's probely
> me how is a bit stupid)
>
> Can you give me a and example on have it works, and have I read the
> string in my action class again.
>
> Thanks
>
> Jeff Beal wrote:
>
>> marc wrote:
>>
>>> I have a jsp page with 3 html:link tags on it. I what all these links
>>> to point to the same action, but each of them need to go to there own
>>> jsp site. So I need to set/pass on a string with each link, so that I
>>> can send the request the right place.
>>>
>>> How do I do that??
>>
>>
>>
>> This is explained in pretty good detail at
>> http://struts.apache.org/userGuide/struts-html.html#link
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by marc <wd...@wilson.dk>.
Have read that 1000 times, don't understand it(I now that it's probely
me how is a bit stupid)
Can you give me a and example on have it works, and have I read the
string in my action class again.
Thanks
Jeff Beal wrote:
> marc wrote:
>
>> I have a jsp page with 3 html:link tags on it. I what all these links
>> to point to the same action, but each of them need to go to there own
>> jsp site. So I need to set/pass on a string with each link, so that I
>> can send the request the right place.
>>
>> How do I do that??
>
>
> This is explained in pretty good detail at
> http://struts.apache.org/userGuide/struts-html.html#link
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Mulitiple html:link but only one action
Posted by Jeff Beal <jb...@webmedx.com>.
marc wrote:
> I have a jsp page with 3 html:link tags on it. I what all these links to
> point to the same action, but each of them need to go to there own jsp
> site. So I need to set/pass on a string with each link, so that I can
> send the request the right place.
>
> How do I do that??
This is explained in pretty good detail at
http://struts.apache.org/userGuide/struts-html.html#link
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org