Fórum

Forward to JSP page from processAction()

Dean Grobler, modificado 12 Anos atrás.

Forward to JSP page from processAction()

Oliver Bayer, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Dean,

if you extend your portlet from GenericPortlet you should be able to use the following code snippet:

...
private String newJSP;

public void init() throws PortletException
{
	...
	// read the path to the new jsp from the init-params of the portlet.xml
	newJSP = getInitParameter("new-jsp");
	...
}

...

public void yourProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
{
	...
	actionResponse.setRenderParameter("jspPage", destGroupsSelectJSP);
}

HTH Oli
thumbnail
Sandeep Nair, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
If you are using MVCPortlet you can use actionResponse.setRenderParameter("jspPage",pathToJSP); inside your processAction

Regards,
Sandeep
thumbnail
Shankar Baba, modificado 10 Anos atrás.

RE: Forward to JSP page from processAction()

Regular Member Postagens: 143 Data de Entrada: 18/10/12 Postagens Recentes
Sandeep Nair:
If you are using MVCPortlet you can use actionResponse.setRenderParameter("jspPage",pathToJSP); inside your processAction

Regards,
Sandeep


Hi Sandeep if i am using serveResource then how can redirect to jsp.As there is no setrenderParameter in Resourceresponse, Any idea??

--Shankar
thumbnail
Sandeep Nair, modificado 10 Anos atrás.

RE: Forward to JSP page from processAction()

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
Resource phase of portlet lifecycle should only be use to serve binary content or make ajax calls. If you want to forward to a jsp after performing your business logic please use the Action phase and then redirect to a view.
asif aftab, modificado 10 Anos atrás.

RE: Forward to JSP page from processAction()

Regular Member Postagens: 123 Data de Entrada: 02/09/13 Postagens Recentes
I am using mvcportlet and to redirect to another jsp I am using setrenderparameter, each and every thing is working and path is looks like path/to/my/view.jsp
but at the time of execution I am getting an error that pat/to/my/view.jsp" not found
from where "&quot" is this one is coming. I searched alot in net but no satisfactory answer that resolve my problem.
please help me
I want to navigate from second.jsp to view.jsp but by using button, I have remedy but by using anchor tag but the problem is I have to use button to navigate
my second.jsp code is

<portlet:actionurl var="viewCall" name="returnView">
	 <portlet:param name="jspPage" value="/html/shop_searc/view.jsp" />
</portlet:actionurl>

<aui:script>
function viewFun()																						//redirect to insert action class
{ 
	 document.getElementById("<portlet:namespace />viewDisplayd").action='&lt;%=viewCall.toString()%&gt;';
	 document.getElementById('<portlet:namespace />viewDisplayd').submit();
	 
} 
</aui:script>

<aui:form name="viewDisplayd" method="post">
		
		 			  <aui:input type="button" value="back" name="hello" onclick="viewFun();"></aui:input>
		 
	</aui:form>

my action class code is

@ProcessAction(name="returnView")
	public void returnView(ActionRequest req, ActionResponse res)
			throws PortletException, SystemException, RemoteException
			{
				res.setRenderParameter("jspPage","/Shop_Search/html/shop_searc/view.jsp");
			
			}
Muhammad Taha, modificado 10 Anos atrás.

RE: Forward to JSP page from processAction()

Junior Member Postagens: 63 Data de Entrada: 01/05/12 Postagens Recentes
Hi Asif, I you just want to navigate to another jsp file you don't have to use action url. u can simply navigate using renderURL.

<portlet:renderurl var="viewCall">
       <portlet:param name="jspPage" value="/html/shop_searc/view.jsp" />
</portlet:renderurl>
asif aftab, modificado 10 Anos atrás.

RE: Forward to JSP page from processAction()

Regular Member Postagens: 123 Data de Entrada: 02/09/13 Postagens Recentes
thanks for your quick reply
Prabodhini Tare, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

New Member Postagens: 6 Data de Entrada: 29/09/10 Postagens Recentes
try using actionResponse.sendRedirect(<<url>>);
Dean Grobler, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

thumbnail
Puneet Upadhyay, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Regular Member Postagens: 234 Data de Entrada: 22/10/11 Postagens Recentes
Make any folder in docroot and place your jsp's there.
and then put this below code into your class....

"response.setRenderParameter("jspPage", "/Any_Folder/view.jsp"); "
thumbnail
Puneet Upadhyay, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Regular Member Postagens: 234 Data de Entrada: 22/10/11 Postagens Recentes
MVC Portlet
thumbnail
Sandeep Nair, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
Hi
Is it possible to attach the portlet. Which portlet are you using? Is it Generic, MVC or Struts portlet

Regards,
Sandeep
Dean Grobler, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Dean Grobler, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Dean Grobler, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

Dean Grobler, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction()

thumbnail
Sandeep Nair, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction() (Resposta)

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
Try this

public class MedelogGetAdmin extends GenericPortlet {
   
    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
   
        //from variables      
        String formType = request.getParameter("formType");
        String buttonClicked = request.getParameter("button");
    
   
        //check what page to forward to
        String jsp = Action.forwardTo(formType, buttonClicked); //jsp = consumers.jsp
       
        actionResponse.setRenderParameter("jsp",jsp);
        //forward to "/WEB-INF/jsp/"+jsp;
        //but how?
       
    }
   
    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {

        //get current tab value
        String currentTab = ParamUtil.getString(request, "currentTab", "Consumers");
       
        //gets data only for requested table
        ResultSet rs = queryDb.queryDb(currentTab.replace(" ",""));
        String javaScript = Tablerize.create(rs);
        request.setAttribute("generatedScript", javaScript);

        //prints out javascript in console for reference
        System.out.println("----------------------------------------------");
        System.out.println(javaScript);
        System.out.println("----------------------------------------------");

        response.setContentType("text/html");

	String jsp = ParamUtil.getString(request,"jsp","MedelogGetAdmin_view.jsp");
        PortletRequestDispatcher dispatcher =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/"+jsp);
        dispatcher.include(request, response);



}
Dean Grobler, modificado 12 Anos atrás.

RE: Forward to JSP page from processAction() (Resposta)