Foros de discusión
How to pass parameter from Button to DoView method
Luca kk, modificado hace 12 años.
How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
Hi all,
in my view.jsp I have this simple button:
I want to pass parameter "value=1" to "DoView" method whe I click on button.
How can I do?
Thanks in advance.
in my view.jsp I have this simple button:
<input name="page1" type="button" class="yt-uix-button-content" value="1">
I want to pass parameter "value=1" to "DoView" method whe I click on button.
How can I do?
Thanks in advance.
David H Nebinger, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Well, I don't know what framework you're using, but it should be available as part of the parameters for the request, although it would also be namespaced.
Luca kk, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
Hi David,
thanks for reply.
You say that:
returns "1"?
thanks for reply.
You say that:
renderRequest.getParameter("value");
returns "1"?
David H Nebinger, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Well, you can try that to be sure, but the parameter might also be namespaced, such as "portlet_myportlet_WAR_myportlet:value". You can grab the list of parameter names and dump it to the log to see what exactly you have to work with...
Luca kk, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
I tried:
but it doesn't work!
request.getParameter("[b]portlet_myPortlet_WAR_myPortlet:value[/b]")
but it doesn't work!
David H Nebinger, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Because the "portlet_myportlet..." thing was just an example to demonstrate how the parameter might be namespaced. Like I said, you'll need to enumerate the parameter names to find the one that you're looking for. Or it might be handled by your particular framework (which you didn't mention).
If the parameter is namespaced, then you will typically iterate through the parameters finding the one that ends with ":value".
But all of this is assuming that you're working at an extremely low level... Aren't you using some sort of framework or something in your portlet development to alleviate having to manage all of these details yourself?
If the parameter is namespaced, then you will typically iterate through the parameters finding the one that ends with ":value".
But all of this is assuming that you're working at an extremely low level... Aren't you using some sort of framework or something in your portlet development to alleviate having to manage all of these details yourself?
Luca kk, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
I use no particular framework.
I developed the portlet with Net Beans, as a simple web application
and deployed it in Liferay.
I developed the portlet with Net Beans, as a simple web application
and deployed it in Liferay.
David H Nebinger, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
As a web application or as a portlet application? Even these will have a different result...
Honestly Luca, it will end up being a heck of a lot easier for you if you identify some framework to leverage, whether it's JSP/Struts2, Spring Web Flow, JSF, Vaadin, etc. Otherwise you're going to spend lots of time down in these kinds of details where a framework will keep you above most of the gore...
Honestly Luca, it will end up being a heck of a lot easier for you if you identify some framework to leverage, whether it's JSP/Struts2, Spring Web Flow, JSF, Vaadin, etc. Otherwise you're going to spend lots of time down in these kinds of details where a framework will keep you above most of the gore...
Luca kk, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
Ok,
I'm using JSP framework.
I'm using JSP framework.
Jitendra Rajput, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
You mean to say you are not getting any form parameter in controller ?
Can you please post yr JSP for more details ..
Can you please post yr JSP for more details ..
Luca kk, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
My jsp is:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineobjects />
<%PortletPreferences prefs = renderRequest.getPreferences();%>
<link rel="stylesheet" type="text/css" href="/html/irma/css/video-list.css">
<link rel="stylesheet" type="text/css" href="/html/irma/css/yt_uix_button.css">
<b>
<input name="page1" type="button" class="yt-uix-button-content" value="1">
</b>
Jitendra Rajput, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
Where is your form element ? How you are submitting form ?..
Luca kk, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Expert Mensajes: 284 Fecha de incorporación: 7/12/10 Mensajes recientes
Hi Jitendra,
the problem is the action attribute.
What do I put in the action to pass parameter "value=1" to the doView method?
The form that I use is:
Regards,
Luca
the problem is the action attribute.
What do I put in the action to pass parameter "value=1" to the doView method?
The form that I use is:
Regards,
Luca
Jitendra Rajput, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
<portlet:actionURL name="nameOfAction" >
<portlet:param name="user" value="myname" />
</portlet:actionURL>
<portlet:param name="user" value="myname" />
</portlet:actionURL>
Jesús Salinas, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
New Member Mensajes: 15 Fecha de incorporación: 1/02/10 Mensajes recientes
Hello,
If you need to pass parameter from a form to a doView method, you have to do something like this:
- JSP Page:
And later, in Java code, you could get this param:
If you need to pass parameter from a form to a doView method, you have to do something like this:
- JSP Page:
<portlet:renderurl var="var1">
<portlet:param name="param1" value="value1">
</portlet:param></portlet:renderurl>
<form action="<%=var1 %>" ...>
...
</form>
And later, in Java code, you could get this param:
...
String param1 = renderRequest.getParameter("param1");
...
David H Nebinger, modificado hace 12 años.
RE: How to pass parameter from Button to DoView method
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
renderUrls are not the same as actionUrls...