Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha November 15, 2012 6:14 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean David H Nebinger November 15, 2012 7:21 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha November 15, 2012 7:41 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha November 15, 2012 9:19 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin November 20, 2012 9:37 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha November 22, 2012 7:46 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin November 24, 2012 2:22 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha December 24, 2012 12:00 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin December 26, 2012 9:10 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha December 26, 2012 8:41 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin December 27, 2012 3:58 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha December 27, 2012 9:17 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha December 27, 2012 7:52 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin January 8, 2013 10:17 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha December 28, 2012 10:51 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin January 8, 2013 10:53 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin January 10, 2013 3:05 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha January 15, 2013 1:03 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin January 15, 2013 11:09 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha January 18, 2013 9:46 PM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin January 19, 2013 3:52 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Muhammad Taha January 25, 2013 6:50 AM
RE: How to Changing JSF portlet View Page in doView or in any managed Bean Neil Griffin January 25, 2013 6:55 AM
Muhammad Taha
How to Changing JSF portlet View Page in doView or in any managed Bean
November 15, 2012 6:14 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
November 15, 2012 7:21 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7252

Join Date: September 1, 2006

Recent Posts

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
November 15, 2012 7:41 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
November 15, 2012 9:19 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
November 20, 2012 9:37 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
November 22, 2012 7:46 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

Yes Neil.. U r correct...
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
November 24, 2012 2:22 PM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
December 24, 2012 12:00 AM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
December 26, 2012 9:10 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
December 26, 2012 8:41 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
December 27, 2012 3:58 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
December 27, 2012 9:17 AM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
December 27, 2012 7:52 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
January 8, 2013 10:17 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
December 28, 2012 10:51 AM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
January 8, 2013 10:53 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
January 10, 2013 3:05 PM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
January 15, 2013 1:03 AM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
January 15, 2013 11:09 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
January 18, 2013 9:46 PM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

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
January 19, 2013 3:52 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

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
January 25, 2013 6:50 AM
Answer

Muhammad Taha

Rank: Junior Member

Posts: 73

Join Date: May 1, 2012

Recent Posts

Thanks Neil.
Neil Griffin
RE: How to Changing JSF portlet View Page in doView or in any managed Bean
January 25, 2013 6:55 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

My pleasure.