Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Help in retrieving html:link paramter value in Action class. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help in retrieving html:link paramter value in Action class." Watch "Help in retrieving html:link paramter value in Action class." New topic
Author

Help in retrieving html:link paramter value in Action class.

yogi reddy
Greenhorn

Joined: Aug 10, 2009
Posts: 18
Hi I am learning sturts 1.3.8 by doing a registaration application.
So far I have completed the "add a new user & list the users" workflow successfully.

I am having a little challenge in editing an user workflow. . I would need someone's help in this. (I will keep trying myself as well)

snapshot of manageusers.jsp
---------------------------
<nested:iterate name="userDetailsForm" property="userDetails">
<tr>
<td>
<html:link action="/editNow" paramName="userDetailsForm" paramProperty="userId" paramId="userId">
<nested:write property="userId" />
</html:link>
</td>
<td>
<nested:write property="firstName" />
</td>
<td>
<nested:write property="lastName" />
</td>
<td>
<nested:write property="email" />
</td>

</tr>
</nested:iterate>


This is the output rendered from manageusers.jsp all the UID WILL HAVE HYPERLINK
--------------------------------------------------------------------------------

UID430 Yogesh Reddy a@b.com
UID440 James Wallach 1@2.com
UID450 Test Tester we@we.com


struts-config.xml
-----------------

<action path="/editNow"
scope="request"
type="com.registration.action.EditUserAction">
<forward name="success"
path="/pages/edituser.jsp" />
</action>

EditUserAction.java
-------------------

public class EditUserAction extends Action {

public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response) {
try{
System.out.println("I am in EditUserAction user id : "+request.getParameter("userId"));
} catch(Exception e) {
System.out.println("I am in EditUserAction Exception : "+e.getMessage());
}
return mapping.findForward(Constants.SUCCESS);
}
}

What I need from you guys ?
***************************

Currently when I click the UID's I am getting the request parameter as null in EditUserAction.
I am sure that I am NOT appending the UID to the hyperlink in manageusers.jsp
because I do not know how to do that (tried couple of approaches but in vain ).

Any thoughts or suggestions on how to do this? Thanks in advance for your time.

Cheers,
Yogesh Reddy
yogi reddy
Greenhorn

Joined: Aug 10, 2009
Posts: 18
Can someone check this and let me know?

Thanks,
Yogesh Reddy
yogi reddy
Greenhorn

Joined: Aug 10, 2009
Posts: 18
I have fixed this.

Yogesh
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help in retrieving html:link paramter value in Action class.
 
Similar Threads
Nested Beans Problem
Need help in retrieving html:link paramter value in Action class.
Problem in SessionManagement in Struts
Using bean:write with html:link
struts form HELP!