Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Pradhip Prakash
Problem in JSF Managed Bean (Request Scope) with portlet
16 de Fevereiro de 2009 00:53
Resposta

Pradhip Prakash

Ranking: New Member

Mensagens: 5

Data de entrada: 16 de Fevereiro de 2009

Mensagens 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
 1<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
 2<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
 3<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 4
 5<f:view>
 6    <p:portletPage>
 7    <h:form id="form2">
 8        <h:outputText value="Simple Text" />
 9        <h:inputText value="#{Page1.page1_str}" />
10       
11        <h:commandButton value="Click" action="#{Page1.click}" />
12    </h:form>
13    </p:portletPage>
14</f:view>


Page2.jsp
 1<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
 2<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
 3<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 4
 5<f:view>
 6    <p:portletPage>
 7    <h:form id="form2">
 8        <h:outputText value="#{Page1.page1_str}" />       
 9    </h:form>
10    </p:portletPage>
11</f:view>


Can anyone please tell me where i am going wrong?

Thanks,

Pradhip.
Deepak Gothe
RE: Problem in JSF Managed Bean (Request Scope) with portlet
16 de Fevereiro de 2009 03:13
Resposta

Deepak Gothe

Ranking: Junior Member

Mensagens: 44

Data de entrada: 19 de Maio de 2008

Mensagens 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
RE: Problem in JSF Managed Bean (Request Scope) with portlet
16 de Fevereiro de 2009 03:58
Resposta

Pradhip Prakash

Ranking: New Member

Mensagens: 5

Data de entrada: 16 de Fevereiro de 2009

Mensagens 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.
Deepak Gothe
RE: Problem in JSF Managed Bean (Request Scope) with portlet
16 de Fevereiro de 2009 04:13
Resposta

Deepak Gothe

Ranking: Junior Member

Mensagens: 44

Data de entrada: 19 de Maio de 2008

Mensagens 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
RE: Problem in JSF Managed Bean (Request Scope) with portlet
16 de Fevereiro de 2009 04:53
Resposta

Pradhip Prakash

Ranking: New Member

Mensagens: 5

Data de entrada: 16 de Fevereiro de 2009

Mensagens recentes

Thanks for the reply.

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

Regards,

Pradhip