Fóruns

Início » Liferay Portal » English » 2. Using Liferay » General

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
Muhammad Taha
How to Changing JSF portlet View Page in doView or in any managed Bean
15 de Novembro de 2012 18:14
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

IM setting event portlet 1 managed bean, and taking value in Portlet2 action file, and setting that value in session and taking that in portlet 2 target bean, I can display that value in same page i.e /views/view.xhtml, But How can i display that value in other page eg. /views/view2.xhtml
David H Nebinger
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
15 de Novembro de 2012 19:21
Resposta

David H Nebinger

Ranking: Liferay Legend

Mensagens: 7238

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Portlets have different portlet sessions. The session for portlet 1 is not the same as the session for portlet 2.

You need to find another mechanism (i.e. portlet IPC, etc.) to transfer the value.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
15 de Novembro de 2012 19:41
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

im not using portlet to portlet session.. im processing event created in portlet1 in portlet2 action using processEvent()..there im setting in session for invoking portlet 2 bean.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
15 de Novembro de 2012 21:19
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

inside portlet1 .xhtml file

<h:inputText value="#{helloBean.name}"></h:inputText>
<h:commandButton action="#{helloBean.set}" value="Add Entry" />

inside portlet1 managed bean

public void set(){
QName qName = new QName("http://liferay.com", "empinfo", "x");
ActionResponse response = (ActionResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.setEvent(qName, name);
}

inside portlet 2 action

public void processEvent(EventRequest request, EventResponse response)throws PortletException, IOException {
Event event = request.getEvent();
String value = (String) event.getValue();
request.getPortletSession().setAttribute("myvalue", value);
}

inside portlet 2 bean (some IpcBean)

public String ipcValue() {
PortletRequest req = (PortletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String myvalue=(String)req.getPortletSession().getAttribute("myvalue");
return myvalue;
}

inside portlet 2 view.xhtml

<h4>Welcome #{ipcBean.ipcValue()}</h4>

Its working for me.. I want to get value in some other eg. view2.xhtml....
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
20 de Novembro de 2012 09:37
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

When you wrote:

I want to get value in some other eg. view2.xhtml


Do you mean that, when an event occurs, that you want to navigate from view1.xhtml to view2.xhtml and then display the received event payload in view2.xhtml?
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
22 de Novembro de 2012 19:46
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

Yes Neil.. U r correct...
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
24 de Novembro de 2012 14:22
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

I would recommend that you look at the jsf2-ipc-events-customers-portlet and jsf2-ipc-events-bookings-portlet demo portlets. They are designed to be used together on the same portal page. When you click on a customer in the customers portlet, it sends an event that is received by the bookings portlet. The bookings portlet then triggers a navigation-rule to fire because of the CustomerSelectedEventHandler.java class. This is a JSR 329 standard feature.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
24 de Dezembro de 2012 00:00
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

Im unable to post new thread using my network....

How to change portlet page using a hidden method (<h:inputHidden > )... waiting for ur reply...
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
26 de Dezembro de 2012 09:10
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

Hi Muhammad,

When you wrote:
How to change portlet page


Do you mean navigating to a different JSF view within the same portlet, or navigating to a totally different Liferay Portal page URL? Also, is this still related to Events IPC?

Thanks,

Neil
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
26 de Dezembro de 2012 20:41
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

its different JSF view within the same portlet. When IPC Event is recieved it has to display a different page instead of page defined in portlet.xml
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
27 de Dezembro de 2012 03:58
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

Did you get an opportunity to try the jsf2-customers-portlet and jsf2-bookings-portlet that I mentioned earlier in this thread? The bookings portlet shows how to execute a navigation-rule -- I think this might be a good match for your requirement of navigating to a different JSF view when the event occurs.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
27 de Dezembro de 2012 09:17
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

Thanks Neil & David. Its done. I've downloaded bookings-portlet using another network..
Im able to do with following code

In porltlet.xml

<init-param>
<name>javax.portlet.faces.bridgeEventHandler</name>
<value>EventHandler</value>
</init-param>

<init-param>
<name>com.liferay.faces.bridge.preferPreDestroy</name>
<value>false</value>
</init-param>

In EventHandler.java

public class EventHandler implements BridgeEventHandler{

public EventNavigationResult handleEvent(FacesContext facesContext, Event event) {
EventNavigationResult eventNavigationResult = null;
String eventName = event.getName().toString();

if (eventName.equals("applicationtrackingnumber")) {

String value=(String) event.getValue();
TargetMO targetMO= getTargetMO(facesContext);

targetMO.setValue(value);

String fromAction = null;
String outcome = "ipc.customerSelected";
eventNavigationResult = new EventNavigationResult(fromAction, outcome);
}

return eventNavigationResult;
}

protected TargetMO getTargetMO(FacesContext facesContext) {

String elExpression = "#{targetMO}";
ELContext elContext = facesContext.getELContext();
ValueExpression valueExpression = facesContext.getApplication().getExpressionFactory().createValueExpression(
elContext, elExpression, TargetMO.class);
return (TargetMO) valueExpression.getValue(elContext);
}
}

in FacesConfig.xml

<navigation-rule>
<navigation-case>
<from-outcome>ipc.customerSelected</from-outcome>
<to-view-id>/views/success.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

Thanks.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
27 de Dezembro de 2012 19:52
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

Hi Neil,

Navigation is working when both source and target portlets are on same page. but if when i put target portlet on another page Eventhandler is invoking but page navigation is not happening.

In source portlet im redirecting and setting event with the follow code

externalContext.redirect(portletURL.toString());
response.setEvent(qNameAppTrackingNumber, applicationTrackingNumber);
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
8 de Janeiro de 2013 10:17
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

Do you have the portlet.event.distribution property set to layout-set in your portal-ext.properties file?

Here is a description from the portal.properties file. Note that a "layout" means a portal page within a site, and "layout-set" means all portal pages within a site.
1    #
2    # Set this property to specify how events are distributed. If the value is
3    # "layout-set", then events will be distributed to all portlets contained in
4    # a layout set. If the value is "layout", then events will be distributed to
5    # all portlets that are present in a layout.
6    #
7    portlet.event.distribution=layout-set


Also, the following need to be set in order for the layout-set distribution feature to work:

1layout.default.p_l_reset=false
2tags.compiler.enabled=false
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
28 de Dezembro de 2012 10:51
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

yes i've already set that. but I don't know why its not working...
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
8 de Janeiro de 2013 10:53
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

I have reproduced the problem and just created FACES-1465 in order to track it to closure. Please click on the "watch" link in JIRA in order to stay informed on progress.
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
10 de Janeiro de 2013 15:05
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

This issue is now fixed and will appear in the GA3 release of Liferay Faces. See FACES-1465 for more info.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
15 de Janeiro de 2013 01:03
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

I tried with EventPayloadWrapper ..but portlet page is not navigating after portal page redirect.

Do I need to wait for latest version of bridge-impl jar ?
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
15 de Janeiro de 2013 11:09
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

You would have to use liferay-faces-bridge-impl-3.1.2-ga3-SNAPSHOT.jar in order for it to work.

For testing in your environment, I would recommend that you download version 3.1.2-ga3-SNAPSHOT of the jsf2-ipc-events-customers-portlet and jsf2-ipc-events-bookings-portlet from the snapshot repository.
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
18 de Janeiro de 2013 21:46
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

Now its working for me Neil...emoticon
I had to use liferay-faces-util-3.1.2-ga3-SNAPSHOT.jar, liferay-faces-bridge-api-3.1.2-ga3-SNAPSHOT.jar along with liferay-faces-bridge-impl-3.1.2-ga3-SNAPSHOT.jar.

I used below code for getting portal page

DynamicQuery query = DynamicQueryFactoryUtil.forClass(PortletPreferences.class).add(PropertyFactoryUtil.forName("portletId").eq("Your Portlet Id"));
List<PortletPreferences> results = (List<PortletPreferences>) PortletPreferencesLocalServiceUtil.dynamicQuery(query);
for(PortletPreferences pre : results) {
Layout layout = LayoutLocalServiceUtil.getLayout(pre.getPlid());
if(currentGroupId==layout.getGroupId()) {
portletURL.append(layout.getFriendlyURL());
break;
}
}
externalContext.redirect(portletURL.toString());

Thanks.
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
19 de Janeiro de 2013 03:52
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

I'm so glad to hear that it's working emoticon

Regarding getting the portal page, there is a contextual class called ThemeDisplay that has lots of getter methods on it that will help you.

You can get it like this in a backing bean:
1FacesContext facesContext = FacesContext.getCurrentInstance();
2ThemeDisplay themeDisplay = (ThemeDisplay) facesContext.getExternalContext.getRequestMap().get(WebKeys.THEME_DISPLAY);


Or if you are using the liferay-faces-portal.jar dependency, you can do this:
1LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
2ThemeDisplay themeDisplay = liferayFacesContext.getThemeDisplay();


In order to get the base URL for the portal, you can call methods like PortalUtil.getPortalURL(PortletRequest);
Muhammad Taha
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
25 de Janeiro de 2013 06:50
Resposta

Muhammad Taha

Ranking: Junior Member

Mensagens: 73

Data de entrada: 1 de Maio de 2012

Mensagens recentes

Thanks Neil.
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
25 de Janeiro de 2013 06:55
Resposta

Neil Griffin

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 2179

Data de entrada: 26 de Julho de 2005

Mensagens recentes

My pleasure.