This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to start an action from a link...

 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have a problem, i have a struts output on my jsp page. for example:

<table>
<s:iterator value="problemVector">
<tr>
<td>
<s roperty value="problemNumber"/>
<s roperty value="problemTitle"/>
<s roperty value="problemDescription"/>
</td>
</tr>
</s:iterator>
</table>

now i would like to display the "problemNumber" as a link, where the User can click on. With this click a new Action should start. How can i do that? and if i would like to use this "problemNumber" value in the following action, how can i access it?

Thank you, for your help!
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Additional javascript function and hidden form variable.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the 'html' namespace I used above, I use:

 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much!

any idea, why :

<html:hidden property="problemNumber" value="" />

the html:hidden Tag is "unknown Tag"
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mine is used on Struts 1.x. The namespace is the one I posted above.

What Struts version are you using?

Just use whatever you use on hidden form fields.
 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using struts 2.

if i change the tag to:

<s:hidden property="problemNumber" value="" />

the problem is, that property is not defined...

Im new into this, so i dont really see the problem, thanks for your help..
[ December 31, 2008: Message edited by: hans meiser ]
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to add that problemNumber in your class.

Define it just like any other form fields in your Struts 2 action class.

Like


[ December 31, 2008: Message edited by: Jesus Angeles ]
 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<action name="Customer_Ticket_Page_Load_From_Overview"
class="de.bamos.ticketsystem.struts.data.CustomerProblemDetailLoad" method="loadFromOverview">
<result name="success">/WEB-INF/jsp/pages/CustomerTicketPage.jsp</result>
<result name="error">/WEB-INF/jsp/pages/Error.jsp</result>
</action>



this is my action...


now how exactly do i have to call it?


<script type="text/javascript" language="javascript">
function goToCase(selectedProblemNumber)
{
document.forms[0].problemNumber.value = selectedProblemNumber;
document.forms[0].action = '<%=request.getContextPath()%>/Customer_Ticket_Page_Load_From_Overview';
document.forms[0].submit();
}
</script>



in this Customer_Ticket_Page_Load_From_Overview Actin class, i will define the problemNumber right?
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define the phoneNumber in the de.bamos.ticketsystem.struts.data.CustomerProblemDetailLoad class.

For how to call, try



without the request path thing.
 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nothing happens if i click on the link...
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way, try

in the javascript



meaning, add the 'action' extension.

If that doesnt work, try below. Below is easier and I actually did on struts 2. (I should have given you this before. The one above is one that I used on struts 1.x; and I thought it would work on struts 2 also).



Note, on the above:
- no javascript
- no hidden variable
- as in first way, add the problemNumber in the action class
[ December 31, 2008: Message edited by: Jesus Angeles ]
 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, the second version works perfect!

Thank you very very much for your help, you saved my day! and the rest of the old year
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. You're welcome. The first one is from my struts 1.x project. I just tried to fit into your struts 2 code but didnt make it. The second one I gave you is from my struts 2 project.

Im glad it worked for you.
[ December 31, 2008: Message edited by: Jesus Angeles ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic