Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.3 how to send link tag name to action class

 
venkat penmatsa
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In Struts 1.3 by using link tag i want to send a value associated with the link clicked to the action class, consider a menu if i am clicking on a particular menu name then that name should be send to the action class.

please help me in resolving my issue.



Thanks in Advance,
venkat.
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Venkat,

You can make link as you make in jsp like test.action?menuname=xyz and get the menuname in the action.

Hope this will works for you.
Regards
Jatan
 
venkat penmatsa
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jatan bhavsar wrote:Hi Venkat,

You can make link as you make in jsp like test.action?menuname=xyz and get the menuname in the action.

Hope this will works for you.
Regards
Jatan



Hi Jatan,

Thanks for your replay , I tried with same code but its not working, getting null value, please check and correct my code.

JSP code
<html:link action="/sample" property="xyz" >Register</html:link>

Struts-config.xml

<action path="/sample" name="SampleForm" validate="true" input="/Sample.jsp" type="com.Action.SampleAction">
<forward name="success" path="/CustomerTable.jsp" />
</action>

Form class
public class SampleForm extends ActionForm {

public String name;
public String xyz;

public String getXyz() {
return xyz;
}

public void setXyz(String xyz) {
this.xyz = xyz;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}


Action class

public class SampleAction extends Action{

public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

SampleForm c=(SampleForm)form;
String a = c.getName();
String b=c.getXyz();
System.out.println("******* Link Name *******"+a);
System.out.println("******* Link Name *******"+b);
return mapping.findForward("success");
}

}





 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic