0

In the following code Sample i am trying to pass param1 value from my jsp to myaction class. When the user clicks on file number i am trying to pass the file number as well as the param1 value.

<display:table   name="sessionScope.List" requestURI="${urlRepDetails}" pagesize='<%= pagesize %>' sort="list" class="displaytag" defaultsort="3" defaultorder="ascending"  >
<display:column href="/myaction.do?param1=xyz"paramId="fileNumber" paramProperty="fileNumber" property="fileNumber" title= 'fileNumber" %>' sortable="true" headerClass="sortable" class="tabel-border"/>
</display:table>

In my action class i am doing is:

if(request.getParameter("param1")=="xyz"){
String REQUEST_NO = request.getParameter("fileNumber");
nextView=callMethod(mapping, form, request, response, REQUEST_NO);
}

But the value param1 is not passed and the control even does not go to the action class on click of the hyperlink. My application is designed in liferay. Generally i call action class as

<display:table   name="sessionScope.List" requestURI="${urlDetail}" pagesize='<%= pagesize %>' sort="list" class="displaytag" defaultsort="3" defaultorder="ascending"  >
    <display:column href="${urlDetails}"paramId="fileNumber" paramProperty="fileNumber" property="fileNumber" title= 'fileNumber" %>' sortable="true" headerClass="sortable" class="tabel-border"/>
    </display:table>

and in my jsp i also have:

<liferay-portlet:renderURL var="urlDetails">
  <liferay-portlet:param name="_xyz" value="/myaction.do" />
  <liferay-portlet:param name="table_select" value="abcd" />
</liferay-portlet:renderURL>

and in action class as:

if(request.getParameter("table_select")!=null && request.getParameter("table_select").equals("abcd")){
                        String REQUEST_NO = request.getParameter("fileNumber");
                        nextView = callMethod(mapping, form, request, response, REQUEST_NO);    

I need to know how to pass values to my action class from href directly?

Sayan
  • 145
  • 2
  • 15
  • You need to understand your JSP is not "calling" any action. The JSP renders HTML, which is then displayed in the browser. Actions in the browser submit HTTP requests back to your server when links are clicked or forms are submitted. So you need to analyse these HTTP requests and work out why your application is not receiving them – cowls Jan 08 '13 at 15:27
  • 2
    Please, take the effort now to leave Struts-1 behind. It offers NO value whatsoever today. Modern JSP trumps a large chunk of what Struts 1 offers, and the rest so marginally above raw servlets it's not worth the effort. At least move up to Struts-2. Java web programming has changed quite a bit in the last 14 years. – Will Hartung Jan 08 '13 at 15:30
  • 2
    are you sure that you are calling the right link to the action ? you should check back the struts config file and also if you are running the web app under some domains, you should include the context path into the called hyperlink <%= request.getContextPath() %> – Thai Tran Jan 08 '13 at 15:51
  • 2
    In the portal world (assuming you're using a struts-based portlet) you cannot request the pure self-made action URL (e.g. ending in *.do), but you'll have to rely on to provide the URL. You're giving too little context here to judge what you're actually doing. – Olaf Kock Jan 08 '13 at 16:02
  • What liferay version? Well I would think if you want to use struts with liferay, won't `struts_action` should be a parameter in the `renderURL`, like ` `, also I hope the struts-config.xml is correct. – Prakash K Jan 09 '13 at 10:09
  • @PrakashK: I am using liferay 5.2.3. is working fine, i guess my struts config does not have any error. what i needed to know is some different approach rather than using – Sayan Jan 09 '13 at 10:14

1 Answers1

0

Seems to be issue with your ActionClass path which you have give

/myaction.do

Make sure the path which you are giving in href is correct with respect to the struts-config file.

Rahul Wagh
  • 470
  • 1
  • 6
  • 23