Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
petar banicevic
Backing bean (JSF, IceFaces) - getting theme object from context ????
24 giugno 2008 12.27
Risposta

petar banicevic

Punteggio: Junior Member

Messaggi: 69

Data di Iscrizione: 27 maggio 2008

Messaggi recenti

Hello,

I need themeDisplay from Liferay into backing bean. I am getting null. Anyone has a clue ?

Here is code:
javax.portlet.PortletRequest req = (javax.portlet.PortletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
RenderRequest renderRequest =(RenderRequest)req.getAttribute("javax.portlet.request");;
ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);


Thanks

PS:

EXAMPLE PORTLET:

Here is a simple portlet that works fine:
<f:view
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:ice="http://www.icesoft.com/icefaces/component"

xmlns:liferay-faces="http://liferay.com/tld/faces"
xmlns:liferay-security="http://liferay.com/tld/security"
xmlns:liferay-theme="http://liferay.com/tld/theme"
xmlns:liferay-ui="http://liferay.com/tld/ui">

<liferay-theme:defineObjects /> -- ADDING THIS MAKES AN EXCEPTION

<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/transitional.dtd" />

<ice:portlet styleClass="componentBoxPortlet">

<ice:outputStyle href="/xmlhttp/css/rime/rime-portlet.css" />
<ice:outputStyle href="./css/showcase_style.css" />

<ice:panelGroup>
<ice:outputConnectionStatus style="float:right;" />
<ice:panelGroup id="treeContentPanel" style="float:left;">
<ice:form>

<ice:panelGroup styleClass="exampleBox">
<ice:outputText value="#{companyInfo.greeting}"/>
</ice:panelGroup>

</ice:form>
</ice:panelGroup>
<ice:panelGroup styleClass="clearer" />
</ice:panelGroup>
</ice:portlet>
</f:view>


EXCEPTION:

Exception: Unsuported, bla bla bla...

aused by: javax.faces.FacesException: Failed to execute JSP lifecycle.
at com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:175)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:504)
... 156 more
Caused by: java.lang.UnsupportedOperationException
at com.icesoft.faces.webapp.parser.StubHttpServletRequest.getAttribute(StubHttpServletRequest.java:116)
at com.liferay.taglib.theme.DefineObjectsTag.doStartTag(DefineObjectsTag.java:42)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:198)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:222)
at com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:159)
... 157 more
16:07:51,986 ERROR [jsp:52] java.lang.UnsupportedOperationException
at com.icesoft.faces.webapp.parser.StubHttpServletRequest.getAttribute(StubHttpServletRequest.java:116)
at com.liferay.taglib.theme.DefineObjectsTag.doStartTag(DefineObjectsTag.java:42)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:198)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:222)
at com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:159)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:504)

LET ME KNOW IF I AM ON WRONG TRACK GO GET THEME FROM BACKING BEAN. DO I NEED THIS TAG THERE? ALSO EXCEPTION DISAPEARS IF I CHANGE <PORTLET-CLASS> IN PORTLET.XML

PORTLET.XML

<portlet>
<portlet-name>CompanyHeader</portlet-name>
<display-name>Company Header</display-name>
<portlet-class>com.icesoft.faces.webapp.http.portlet.MainPortlet</portlet-class>
<init-param>
<name>com.icesoft.faces.portlet.viewPageURL</name>
<value>/Test.iface</value>
</init-param>


Please help.
Lari Tuominen
RE: Backing bean (JSF, IceFaces) - getting theme object from
24 giugno 2008 13.01
Risposta

Lari Tuominen

Punteggio: Expert

Messaggi: 283

Data di Iscrizione: 7 novembre 2007

Messaggi recenti

Hi Petar, You don't need that tag (as far as I know). I'm using Liferay 5.0.1 and my portlet is based on JSF, ICEFaces 1.7.....

Try the following on your backing bean:

FacesContext fc = FacesContext.getCurrentInstance();
ThemeDisplay themeDisplay = (ThemeDisplay)fc.getExternalContext().getRequestMap().get(WebKeys.THEME_DISPLAY);

BR, Lari
petar banicevic
RE: Backing bean (JSF, IceFaces) - getting theme object from
24 giugno 2008 13.27
Risposta

petar banicevic

Punteggio: Junior Member

Messaggi: 69

Data di Iscrizione: 27 maggio 2008

Messaggi recenti

You are right, the tag is not needed.
There is a bug in liferay-icefaces that it does not forward this object to context.
Solution is here thanks to http://jira.icefaces.org/browse/ICE-2247