Foros de discusión
How to pass actionRequest params to the form
jam dah, modificado hace 9 años.
How to pass actionRequest params to the form
Junior Member Mensajes: 43 Fecha de incorporación: 13/08/14 Mensajes recientes
Hi,
I have created a portlet action, wherei retreive data from the form.Then i tried to forward data to the the form.
Any idea to do it ?
Thanks
I have created a portlet action, wherei retreive data from the form.Then i tried to forward data to the the form.
Any idea to do it ?
Thanks
Mayur Patel, modificado hace 9 años.
RE: How to pass actionRequest params to the form
Expert Mensajes: 358 Fecha de incorporación: 17/11/10 Mensajes recientes
Please try this :
In process action :
actionRequest.setAttribute("paramName", paramValue);
In render method :
String value= renderRequest.getAttribute("paramName");
renderRequest.setAttribute("paramName", value);
In JSP:
String value= (String) request.getAttribute("paramName");
Thanks.
In process action :
actionRequest.setAttribute("paramName", paramValue);
In render method :
String value= renderRequest.getAttribute("paramName");
renderRequest.setAttribute("paramName", value);
In JSP:
String value= (String) request.getAttribute("paramName");
Thanks.
jam dah, modificado hace 9 años.
RE: How to pass actionRequest params to the form
Junior Member Mensajes: 43 Fecha de incorporación: 13/08/14 Mensajes recientes
Hi,
I want to sent a list to populate the right list of the input-move-boxes.
Really, i didn't understand so much wich param i have to put.
view.jsp:
what i want is when i select a channel from the list, the right list of the input-move-boxes got the appropriate data.
in my process action
I want to sent a list to populate the right list of the input-move-boxes.
Really, i didn't understand so much wich param i have to put.
view.jsp:
<<%
List leftBox = new ArrayList(), rightBox = new ArrayList();
leftBox.add(new KeyValuePair("1", "Player1"));
leftBox.add(new KeyValuePair("2", "Player2"));
leftBox.add(new KeyValuePair("3", "Player3"));
leftBox.add(new KeyValuePair("4", "Player4"));
leftBox.add(new KeyValuePair("5", "Player5"));
%>
<form action="<%= actionURL1 %>" method="post" name="<portlet:namespace />fm">
<aui:select name="selectChannel" label="Select a channel">
<aui:option value="channel1"> Channel1</aui:option>
<aui:option value="channel2"> Channel2</aui:option>
<aui:option value="channel3"> Channel3</aui:option>
<aui:option value="channel4"> Channel4</aui:option>
<aui:option value="channel5"> Channel5</aui:option>
</aui:select>
<liferay-ui:input-move-boxes rightlist="<%= request.getAttribute(\" playerslist\")%>"
rightTitle="Selected Players"
leftBoxName="allFieldsList"
leftList="<%=leftBox%>"
rightBoxName="displayFieldsList"
leftTitle="available Players"
leftReorder="false"
rightReorder="true"
cssClass="custom-move-boxes" />
<input name="<portlet:namespace />hiddenLeftFields" id="<portlet:namespace />hiddenLeftFields" type="hidden">
<input name="<portlet:namespace />hiddenRightFields" id="<portlet:namespace />hiddenRightFields" type="hidden">
<center><input onclick="<portlet:namespace />submitForm();" type="button" value="Validate" cssClass=".submitButton">
</center>
</liferay-ui:input-move-boxes></form>
what i want is when i select a channel from the list, the right list of the input-move-boxes got the appropriate data.
in my process action
package com.service.distribution;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.xpath.XPathExpressionException;
import org.xml.sax.SAXException;
import com.liferay.calendar.model.Calendar;
import com.liferay.calendar.service.CalendarLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.netcenter.tools.NetcenterTools;
import com.netcenter.tools.ParserXml;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class DistributionPortlet extends MVCPortlet {
NodeList channel = null;
Element element = null;
List channelList = null;
NodeList players = null;
@Override
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
String selectChannel = ParamUtil.getString(actionRequest, "selectChannel");
System.out.println("Selected channel" +selectChannel);
String displayFields = ParamUtil.getString(actionRequest,
"hiddenRightFields");
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
if ((selectChannel != null) && (displayFields != null)) {
FileEntry fileEntry;
try {
fileEntry = DLAppServiceUtil.getFileEntry(themeDisplay
.getLayout().getGroupId(), 0, "Distribution");
String pathFileDestion = NetcenterTools
.getDLFileAbsPath(fileEntry);
File file = new File(pathFileDestion);
System.out.println("-------------------File path--------------------");
System.out.println(pathFileDestion);
/////////////////////////////////////////////////////////////////////////////////////////
//parse the xml file with the selected channel to resent it to the form
System.out.println("---------------------------------------------------------------");
System.out.println("------------------Associated Players----------------------");
channel = ParserXml.getChannels(file);
List<string> playersList = new ArrayList<string>();
Element e=null;
for(int i = 0; i < channel.getLength(); i++){
element = (Element) channel.item(i);
if((element.getAttribute("name").equals(selectChannel))&&(element.hasChildNodes())){
players = element.getElementsByTagName("player");
System.out.println("Channel id -----: " + element.getAttribute("name"));
System.out.println("players number: " + element.getElementsByTagName("player").getLength());
for(int k = 0; k<players.getlength();k++){ e="(Element)" players.item(k); retrive all players in the channel system.out.println("player id -------: " + e.getattribute("id")); playerslist.add(e.getattribute("id")); system.out.println(playerslist.get(0)); } actionrequest.setattribute("playerslist", playerslist); catch (portalexception e) { e.printstacktrace(); (systemexception (numberformatexception (xpathexpressionexception (saxexception (transformerfactoryconfigurationerror (transformerexception (parserconfigurationexception super.processaction(actionrequest, actionresponse); < code></players.getlength();k++){></string></string>
<br>thanks
Mayur Patel, modificado hace 9 años.
RE: How to pass actionRequest params to the form
Expert Mensajes: 358 Fecha de incorporación: 17/11/10 Mensajes recientes
Hi Jam,
You have to create list of key/value pair in action method to pass in jsp.
In action method,
In render method,
Thanks.
You have to create list of key/value pair in action method to pass in jsp.
In action method,
List<keyvaluepair> displayFields = makeKeyValuePar(leftValuesArray);
actionRequest.setAttribute("displayFields", displayFields);
//you can use below method to generate list of key/value pair which we need to pass in rightBox
private static List<keyvaluepair> makeKeyValuePar(String[] values) {
List<keyvaluepair> keyValuePairList = new ArrayList<keyvaluepair>();
for (String val : values) {
val = ListingUtils.columnNameStaticMapping(val);
KeyValuePair obj = new KeyValuePair();
obj.setKey(val);
obj.setValue(val);
keyValuePairList.add(obj);
}
return keyValuePairList;
}</keyvaluepair></keyvaluepair></keyvaluepair></keyvaluepair>
In render method,
renderRequest.setAttribute("displayFields", renderRequest.getAttribute("displayFields"));
Thanks.