Foros de discusión

displaying item page

sasmita swain, modificado hace 11 años.

displaying item page

Regular Member Mensajes: 183 Fecha de incorporación: 24/02/12 Mensajes recientes
hi

i want to display item page when you click subcategory link means once you click subcategory link items page will display in shopping portlet

here my code is

<portlet:renderURL var="redirectURL">
<portlet:param name="struts_action" value="/shopping/view_item" />
<portlet:param name="redirect" value="<%= currentURL %>" />
</portlet:renderURL>

<aui:button href="<%= redirectURL %>" value="<%=shoppingCategory1.getName() %>"/>

item page is not displaying..error showing like

Current URL /web/guest/home?p_p_id=34&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_34_struts_action=%2Fshopping%2Fview_item&_34_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D34%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1 generates exception: An exception occurred processing JSP page /html/portlet/shopping/view_item.jsp at line 24

21:
22: ShoppingItem item = (ShoppingItem)request.getAttribute(WebKeys.SHOPPING_ITEM);
23:
24: item = item.toEscapedModel();
25:
26: ShoppingItemField[] itemFields = (ShoppingItemField[])ShoppingItemFieldLocalServiceUtil.getItemFields(item.getItemId()).toArray(new ShoppingItemField[0]);
27: ShoppingItemPrice[] itemPrices = (ShoppingItemPrice[])ShoppingItemPriceLocalServiceUtil.getItemPrices(item.getItemId()).toArray(new ShoppingItemPrice[0]);


Stacktrace:
08:17:07,967 ERROR [IncludeTag:154] java.lang.NullPointerException
at org.apache.jsp.html.portlet.shopping.view_005fitem_jsp._jspService(view_005fitem_jsp.java:660)

how to solve this prbleme????
thumbnail
Pavel Savinov, modificado hace 11 años.

RE: displaying item page

Junior Member Mensajes: 94 Fecha de incorporación: 24/09/12 Mensajes recientes
To display an item with view_item you have to pass item in the request.
Now you have NPE because it's impossible to get an item. Just add the item to the request.
sasmita swain, modificado hace 11 años.

RE: displaying item page

Regular Member Mensajes: 183 Fecha de incorporación: 24/02/12 Mensajes recientes
Pavel Savinov:
To display an item with view_item you have to pass item in the request.
Now you have NPE because it's impossible to get an item. Just add the item to the request.



can you give example??
sasmita swain, modificado hace 11 años.

RE: displaying item page

Regular Member Mensajes: 183 Fecha de incorporación: 24/02/12 Mensajes recientes
can anybody help me???
sasmita swain, modificado hace 11 años.

RE: displaying item page

Regular Member Mensajes: 183 Fecha de incorporación: 24/02/12 Mensajes recientes
<portlet:actionURL var="itemUrl">
<portlet:param name="struts_action" value="/shopping/view_item" />

<portlet:param name="redirect" value="<%= currentURL %>" />

</portlet:actionURL>
<aui:form action="<%= itemUrl %>" method="post" name="fm">
<div>
<aui:button href="<%= itemUrl %>" value="<%=shoppingCategory1.getName() %>"/></div></aui:form>

error is:

This URL can only be invoked using POST: /web/guest/home?p_auth=Bddp8ywV&p_p_id=34&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_34_struts_action=%2Fshopping%2Fview_item&_34_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D34%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1
10:58:54,702 ERROR [render_portlet_jsp:154] com.liferay.portal.security.auth.PrincipalException: /web/guest/home?p_auth=Bddp8ywV&p_p_id=34&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_34_struts_action=%2Fshopping%2Fview_item&_34_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D34%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1
at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:171)
at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:190)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:651)
at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:686)
at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:361)
at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:845)
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:633)
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:244)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:174)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:533)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

how to resolve?
thumbnail
Pavel Savinov, modificado hace 11 años.

RE: displaying item page

Junior Member Mensajes: 94 Fecha de incorporación: 24/09/12 Mensajes recientes
You need to add itemId as a parameter to your URL:
<portlet:renderurl var="redirectURL">
<portlet:param name="struts_action" value="/shopping/view_item" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="itemId" value="<%= String.valueOf(item.getItemId()) %>" />
</portlet:renderurl>

item is the item object that you want to show.

Try to explore shopping portlet source code, it's clear and very interesting, I think, that you'll find many answers there.
sasmita swain, modificado hace 11 años.

RE: displaying item page

Regular Member Mensajes: 183 Fecha de incorporación: 24/02/12 Mensajes recientes
Pavel Savinov:
You need to add itemId as a parameter to your URL:
<portlet:renderurl var="redirectURL">
<portlet:param name="struts_action" value="/shopping/view_item" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="itemId" value="<%= String.valueOf(item.getItemId()) %>" />
</portlet:renderurl>

item is the item object that you want to show.

Try to explore shopping portlet source code, it's clear and very interesting, I think, that you'll find many answers there.


thanks for reply

error is showing after writing this code,

Current URL /web/guest/home?p_p_id=34&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_34_struts_action=%2Fshopping%2Fview_item&_34_jspPage=%2Fshopping%2Fview_item.jsp&_34_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D34%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1 generates exception: An exception occurred processing JSP page /html/portlet/shopping/view_item.jsp at line 24

21:
22: ShoppingItem item = (ShoppingItem)request.getAttribute(WebKeys.SHOPPING_ITEM);
23: System.out.println(item);
24: item = item.toEscapedModel();
25:
26: ShoppingItemField[] itemFields = (ShoppingItemField[])ShoppingItemFieldLocalServiceUtil.getItemFields(item.getItemId()).toArray(new ShoppingItemField[0]);
27: ShoppingItemPrice[] itemPrices = (ShoppingItemPrice[])ShoppingItemPriceLocalServiceUtil.getItemPrices(item.getItemId()).toArray(new ShoppingItemPrice[0]);


Stacktrace:
03:21:56,556 ERROR [IncludeTag:154] java.lang.NullPointerException
at org.apache.jsp.html.portlet.shopping.view_005fitem_jsp._jspService(view_005fitem_jsp.java:660)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: displaying item page

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
There should be a "caused by" row in the stacktrace little further down. This row should tell you what's wrong.
sasmita swain, modificado hace 11 años.

RE: displaying item page

Regular Member Mensajes: 183 Fecha de incorporación: 24/02/12 Mensajes recientes
Hitoshi Ozawa:
There should be a "caused by" row in the stacktrace little further down. This row should tell you what's wrong.



how to do if i am clicking one subcategory item based on that category item should be displayed..i am trying a lot but i am not getting.

Thanks

Sasmita
thumbnail
Pavel Savinov, modificado hace 11 años.

RE: displaying item page

Junior Member Mensajes: 94 Fecha de incorporación: 24/09/12 Mensajes recientes
sasmita swain:

error is showing after writing this code,

Current URL /web/guest/home?p_p_id=34&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_34_struts_action=%2Fshopping%2Fview_item&_34_jspPage=%2Fshopping%2Fview_item.jsp&_34_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D34%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1 generates exception: An exception occurred processing JSP page /html/portlet/shopping/view_item.jsp at line 24

21:
22: ShoppingItem item = (ShoppingItem)request.getAttribute(WebKeys.SHOPPING_ITEM);
23: System.out.println(item);
24: item = item.toEscapedModel();
25:
26: ShoppingItemField[] itemFields = (ShoppingItemField[])ShoppingItemFieldLocalServiceUtil.getItemFields(item.getItemId()).toArray(new ShoppingItemField[0]);
27: ShoppingItemPrice[] itemPrices = (ShoppingItemPrice[])ShoppingItemPriceLocalServiceUtil.getItemPrices(item.getItemId()).toArray(new ShoppingItemPrice[0]);


Stacktrace:
03:21:56,556 ERROR [IncludeTag:154] java.lang.NullPointerException


Sasmita, you didn't passed shopping item, and still got the same NPE.