This content has been marked as final.
Show 4 replies
-
1. Re: processAction in Jboss portals
arvind_pv Nov 28, 2005 5:03 AM (in response to udaiibhaskar)Hi,
I'm also a newbie to the Portal Specification, please check the code given below.public class SearchPortlet extends GenericPortlet { private boolean resultsFlag = false; public static final String VIEW_RESULT = "/jsp/Results.jsp"; public static final String VIEW_JSP = "/jsp/SearchView.jsp"; public void init(PortletConfig portletConfig) throws UnavailableException, PortletException { super.init(portletConfig); } protected void doView(RenderRequest request, RenderResponse response)throws PortletException, IOException { response.setContentType(request.getResponseContentType()); PortletRequestDispatcher portletRequestDispatcher = null; if(resultsFlag) { portletRequestDispatcher = context.getRequestDispatcher(VIEW_RESULT); } else { portletRequestDispatcher = context.getRequestDispatcher(VIEW_JSP); } portletRequestDispatcher.include(request, response); } public void processAction(ActionRequest request, ActionResponse esponse) throws PortletException, java.io.IOException { String keyword=request.getParameter("keyword"); String category=request.getParameter("category"); String location=request.getParameter("location"); SearchBO keyCateLoc=new SearchBO(); boolean yes=keyCateLoc.searchKCLBo(keyword, category, location); resultsFlag = yes; } }
-
2. Re: processAction in Jboss portals
bsmithjj Nov 28, 2005 2:20 PM (in response to udaiibhaskar)Hello,
Your portlets should be designed thread safe - like servlets. So your usage of an instance variable,resultsFlag
, will only work as long as your portlet handles a single request from a single user. The moment two different users use invoke the processAction(), you will have contention issues for the correct value of resultsFlag.
Also, notice in your code that you never reset resultsFlag to false, so once it gets set to true, it's always true!
Cheers. -
3. Re: processAction in Jboss portals
arvind_pv Nov 28, 2005 10:59 PM (in response to udaiibhaskar)Hi bsmithjj,
I thank you for giving me valuable suggestion.
Arvind -
4. Re: processAction in Jboss portals
udaiibhaskar Nov 29, 2005 12:01 AM (in response to udaiibhaskar)Hi bsmithjj and arvind,
Thank for ur help.
bye,
uday.