Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
George Stafford
Portlet Routing Problems
November 19, 2012 10:46 AM
Answer

George Stafford

Rank: Junior Member

Posts: 62

Join Date: October 1, 2012

Recent Posts

Hi All,

I'm attempting to build some portlets and keep running into issues limited by my Java experience and deadline crunches. What I'm attempting at the moment is a selection page that posts to a display page that contains a Jasper report. What I am trying to determine is how to set conditional view methods. I'm using MVCPortlet and I have the following action request:

 1   
 2@ProcessAction(name = "getFundingStatusAction")
 3public void getFundingStatusAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException {
 4
 5        String[] selectedCountries = actionRequest.getParameterValues("countryList");
 6
 7        if (selectedCountries != null) {
 8            //actionRequest.setAttribute("countryList", selectedCountries);
 9            actionRequest.getPortletSession().setAttribute("selectedCountries", selectedCountries);
10            
11            actionResponse.setRenderParameter("jspPage", "/html/fundingstatus/fundingstatus_report.jsp");
12        }
13 }


When my portlet routes to fundingstatus_report.jsp my generic doView is not being called.

My question is how do I tell the actionResponse what the Render View method should be?

Thanks!
Vipin Bardia
RE: Portlet Routing Problems
November 19, 2012 1:21 PM
Answer

Vipin Bardia

Rank: Regular Member

Posts: 103

Join Date: February 27, 2011

Recent Posts

Hi George,

It's a default behavior of portlet that after any Action, doView will be called immediately.
Still if you are facing some issue then override doView method in your own class.

Set parameters & write your own conditions on that basis in doView method.

Regards,
Vipin Bardia
George Stafford
RE: Portlet Routing Problems
November 19, 2012 1:24 PM
Answer

George Stafford

Rank: Junior Member

Posts: 62

Join Date: October 1, 2012

Recent Posts

Hey Vipin,

Thanks for the response - but the doView is NOT being called when I use the renderParameter and a key of jspPage. It's getting skipped. I also tried it as a GenericPortlet with the same result.
Gwowen Fu
RE: Portlet Routing Problems
November 19, 2012 2:32 PM
Answer

Gwowen Fu

Rank: Expert

Posts: 253

Join Date: December 27, 2010

Recent Posts

Please check out this method:
void javax.portlet.StateAwareResponse.setRenderParameter(String key, String value)

if the value is blank then it will redirect to the default page, otherwise you can specify the view to go to.
George Stafford
RE: Portlet Routing Problems
November 20, 2012 5:42 AM
Answer

George Stafford

Rank: Junior Member

Posts: 62

Join Date: October 1, 2012

Recent Posts

I have that set - but it's not calling the general doView for the portlet. How do I tell the jsp page/view what function to call within the base class?
Gwowen Fu
RE: Portlet Routing Problems
November 20, 2012 1:22 PM
Answer

Gwowen Fu

Rank: Expert

Posts: 253

Join Date: December 27, 2010

Recent Posts

Liferay Portal 6.1 - Development Guide has very good tutorials.

Check out "Writing the My Greeting Portlet" at
http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/writing-the-my-greeting-portl-4
George Stafford
RE: Portlet Routing Problems
November 26, 2012 10:33 AM
Answer

George Stafford

Rank: Junior Member

Posts: 62

Join Date: October 1, 2012

Recent Posts

Any other ideas out there? Does the display for the secondary portion need to be in a new portlet? I know a portion of my problem is just understanding portlets in general. Maybe my workflow is incorrect? What I'm trying to do is the following:

Initial View with Combo Box and Form -> Posts to Action -> Load second jsp as View -> Provide reset button which posts to Action -> Displays combo box and form like Initial view.

Thanks,
George
Abhed Dekavadiya
RE: Portlet Routing Problems
November 26, 2012 12:21 PM
Answer

Abhed Dekavadiya

Rank: Junior Member

Posts: 70

Join Date: October 5, 2010

Recent Posts

In your action-method, try with the parameter-name as mvcPath rather than jspPage.

OR

After action it goes to render() method. Try overriding render method in your custom portlet class.
1    @Override
2    public void render(RenderRequest request, RenderResponse response)
3            throws PortletException, IOException {
4        // TODO Auto-generated method stub
5        super.render(request, response);
6    }


OR

If you don't have any conditional decision for view-jsp (after action), then below also works from the jsp
1<portlet:actionURL var="editGreetingURL">
2    <portlet:param name="mvcPath" value="/view.jsp" />
3</portlet:actionURL>


Good luck !
George Stafford
RE: Portlet Routing Problems
November 27, 2012 11:48 AM
Answer

George Stafford

Rank: Junior Member

Posts: 62

Join Date: October 1, 2012

Recent Posts

So what I figured out from actually reading the Liferay in Action book was that when extending an MVCPortlet it skips the doView per design. Once I got through this and loaded my responses in the action phase then set the renderParameter I was able to get my work flow flowing. RTFM, ugh! emoticon