Fórum

Problem in JSF Managed Bean (Request Scope) with portlet

Pradhip Prakash, modificado 15 Anos atrás.

Problem in JSF Managed Bean (Request Scope) with portlet

New Member Postagens: 5 Data de Entrada: 16/02/09 Postagens Recentes
Hi,

I have made a simple web portlet project in Netbeans 6.1 with JSF 1.2 & portlet 2.0
deployed in liferay (5.1)/websynergy/glassfish 5.0.1 server.

I have a JSF Page1.jsp that takes an input in a text field. On clicking the button, Page2.jsp is displayed which will display the input value.

Page1.jsp & Page2.jsp are using ManagedBean Page1.java.

The managed bean is configured in 'request' scope in faces-config.xml.

I am not able to get the value in Page2.jsp. But, if I change the scope to 'session', value gets displayed.

I am posting the Page1.jsp & Page2.jsp here.

Page1.jsp
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<f:view>
    <p:portletpage>
    <h:form id="form2">
        <h:outputtext value="Simple Text" />
        <h:inputtext value="#{Page1.page1_str}" />
        
        <h:commandbutton value="Click" action="#{Page1.click}" />
    </h:form>
    </p:portletpage>
</f:view>


Page2.jsp
&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %&gt;
&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %&gt;
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

<f:view>
    <p:portletpage>
    <h:form id="form2">
        <h:outputtext value="#{Page1.page1_str}" />        
    </h:form>
    </p:portletpage>
</f:view>


Can anyone please tell me where i am going wrong?

Thanks,

Pradhip.
thumbnail
Deepak Gothe, modificado 15 Anos atrás.

RE: Problem in JSF Managed Bean (Request Scope) with portlet

Junior Member Postagens: 44 Data de Entrada: 19/05/08 Postagens Recentes
This because of the request scope differences between JSF and Portlets. In case of JSF web application request is the same for both action and render. But in case of portlets, the request is different for action and render. So when you submit after entering a value in textfield, it will be in action request scope. But when it gets rendered it will be in render request scope, which is a new request, hence the value is lost. So you should avoid request scope in case of jsf portlets.

Regards,
Deepak
Pradhip Prakash, modificado 15 Anos atrás.

RE: Problem in JSF Managed Bean (Request Scope) with portlet

New Member Postagens: 5 Data de Entrada: 16/02/09 Postagens Recentes
Thanks for the reply.

But our application is huge and handling of huge data in session will make it more complex.

Is there any other way to handle this.

Thanks,

Pradhip.
thumbnail
Deepak Gothe, modificado 15 Anos atrás.

RE: Problem in JSF Managed Bean (Request Scope) with portlet

Junior Member Postagens: 44 Data de Entrada: 19/05/08 Postagens Recentes
If you are using JSF Portlet bridge from https://jsfportletbridge.dev.java.net/ ..a new feature has been introduced to support such cases in version 1.2.3. Check the Issue 30 for more details..

Regards,
Deepak
Pradhip Prakash, modificado 15 Anos atrás.

RE: Problem in JSF Managed Bean (Request Scope) with portlet

New Member Postagens: 5 Data de Entrada: 16/02/09 Postagens Recentes
Thanks for the reply.

I downloaded the latest jsf-portlet.jar (v1.2.3) and it worked !!

Regards,

Pradhip