Apps RN commented on Jan 11, 2012

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Thanks a lot for your reply Jan.

We need to get some JSON data when the user clicks on a particular link in the JSP. Also we need to pass some parameter based on the link which is clicked. We thought to use the serveResourcee() method to provide the JSON data. We could have constructed the serveResource() URL when the JSP loads. But we thought we will construct it only when the user clicks on the particular link.

Since we are just using the href from the atom feed, and then send a request to this href, I was curious to know if we could do that in a single request by passing some additional information.

Jan-Paul Buchwald commented on Jan 10, 2012

Re: IBM WebSphere Portal Remote State Service and Fragment Service

To Apps RN: I am not aware of any way to achieve a single request that combines the URL encoding and Portal page (including output of portlet resource methods) delivery. In this particular case I wonder about the use case behind this, why isn't it possible to generate the resource URL on the server and use resource ids or parameters for dynamic information?

Apps RN commented on Jan 9, 2012

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Hi Jan,

I have a very simple question regarding the Remote State Service. Suppose I need to get the JSON data by invoking the serveResource() method of a particular portlet. I make a request to the content handler service with the state information and I get the feed. From the feed I get the URL and then I make a request to that URL. So in total, I'm making two requests to get the Data. Can I do this in a single HTTP Request? Could you please let me know?

Apps RN commented on Nov 28, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Ok. I got it, I was not using ContentHandler to encode the state.

Apps RN commented on Nov 28, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

the HTML characters got converted. This is the response that I got when I decoded the Portal URL.

<root><state type="navigational"><selection selection-node="6_D8LAOSQ400GO80IH2Q69VG2863"/><locale>en_US</locale></state></root>

Apps RN commented on Nov 28, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Hi,

I tried using the RemoteStateService. First to test it, I decoded the Portal URL to get the XML file. This is what i got.

en_US

Now to construct a portal url with this state, I tried

var xmlDoc = com.ibm.portal.xslt.loadXml("/wps/poc" + "?uri=" + encodeURIComponent("state:" + state) + "&mode=download");

where "state" is the above Navigation State XML. But I get Error 400

Error 400: EJCBC0006E: A URISyntaxException occurred during the resolution process for URI [state:<root>

<state type="navigational">

<selection selection-node="6_D8LAOSQ400GO80IH2Q69VG2863"/>

<locale>th_TH</locale>

</state>

</root>]. The causing exception reported: [Illegal character in opaque part at index 6: state:<root>

<state type="navigational">

<selection selection-node="6_D8LAOSQ400GO80IH2Q69VG2863"/>

<locale>en_US</locale>

</state>

</root>].

Can you please help me to fix this?

Jan-Paul Buchwald commented on Aug 22, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Hi Jishnu,

thanks for your explanations.

The fragment service can not be used to break through the page and portlet model (i.e. run portlet instance p in the context of page a although it is placed on page b). Doing otherwise would quickly lead to inconsistencies in the Portal internal model and state handling. This limitation does only affect those use cases where you make use of server side context information, such as the current page selection, in your portlet. For your particular scenario, I would either recommend to pass on the context information as explicit parameters to the portlet, or move the respective logic to a global component (such as a portlet service or servlet).

I had written the article more with the "view" use case in mind, I will edit it to add a respective statement.

Jishnu R commented on Aug 19, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Hi Jan,

Thank you so much for your reply.

I've a portlet which is kept on a page say Page A. This is a JSF Portlet and it has code written to call a Managed bean action method on a button click.

Now I'm getting the fragment of this portlet in my Theme which is set for a different page say PageB. This is working fine.

Now when I click on the button, it calls the managed bean action method. in that method I get the Unique Name of the selected page using NavigationSelectionModel. This returns me the unique name of the page where this portlet is kept ie Page A and NOT the unique name of the page where I loaded the fragment ie Page B.

So I guess the action URL that was created in the Target Portlet has the selection information of the page where that portlet is kept. So that means, the FragmentService internally selects that Target Page and then renders the Portlet.(Hope my understanding is correct).

This is exactly what generateFlyoutUrl() method of URL Helper class do. This selects the target page.

I guess the only advantage of using the FragmentService is we don't need to have access to any Portal APIs to construct the URL. Could you please let me know if the understanding is correct?

My concern was, is it possible to generate the fragment without enabling the selection of the page where the portlet is kept.

Jan-Paul Buchwald commented on Aug 19, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

@Jishnu: I would need some more background information on the scenario and use case to answer this question precisely. Where exactly do you see that the selected page changes, is this in links contained in the portlet or also in the navigation links in the theme? From where do you call the fragment service and how do you handle the result?

Jishnu R commented on Aug 18, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

Thanks for your reply. I'm able to download the feed now.

One more question, I have a requirement to get the markup of a portlet which is on a different page. I'm able to get the markup and insert it. That is fine. This updates the selected page information to the page where the portlet whose markup is required is kept. Is it possible to get the markup without changing the selected page information? Could you please let me know?

Jan-Paul Buchwald commented on Aug 18, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

To Jishnu's comments:

It looks like the URL used here is a friendly URL or URL mapping - the portlet provided here has not been tested with friendly URLs or URL mappings. Does the same operation work when using the "non-friendly" encoded Portal URL for the page where the portlet is placed? Also, for 404 errors the Portal server SystemOut.log may provide further clues on what might be wrong.

Jishnu R commented on Aug 18, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

This is what I did.

http://localhost:10039/wps/myportal/test/general/?uri=fragment:pm:oid:com.test.generalpage@oid:com.test.aboutwps.portlet&mode=download

Is this correct?

Jishnu R commented on Aug 18, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

This is what I did.

http://localhost:10039/wps/myportal/test/general/?uri=fragment:pm:oid:com.test.generalpage@oid:com.test.aboutwps.portlet&mode=download

Is this correct?

Jishnu R commented on Aug 18, 2011

Re: IBM WebSphere Portal Remote State Service and Fragment Service

I added the portlet to a page,and tried to create the Portlet Fragment using Remote State and Fragment API Explore Portlet. I provided the unique name of the page and portlet window ID. But in firebug console, I always get 404 error. "Failed to load the resource". Is there anything else that I should enable? Could you please let me know.?

Jan-Paul Buchwald commented on Nov 17, 2010

IBM WebSphere Portal Remote State Service and Fragment Service

To answer the previous question precisely, more information on the overall scenario or use case would be required. In general, combining the fragment service with JSF portlets is difficult, as it may conflict with the JSF life cycle or the JSF widget library elements (which in some cases come with partial refresh features themselves). A way to execute JS code inserted through the innerHTML property would be to extract single JS methods from the new markup and pass it as an argument to the JavaScript eval() method. But this is not very elegant and may become quite effort-prone, so I would recommend to double check whether using the fragment service makes really sense in this context.

Apps RN commented on Nov 17, 2010

IBM WebSphere Portal Remote State Service and Fragment Service

Hi,

I have one question regarding execution of JS functions in the returned markup. I've a JSF portlet and was able to retrieve the markup of that portlet using the above approach. But there are certain JS methods in that porltet. I need to do some actions on that portlet and execute some JS methods. I read that it is not possible to execute the JS methods that are inserted using innerHTML() property. Could you please suggest some methods on how to do execute action method of that portlet?

Regards,

Apps.

John Munnell commented on Mar 31, 2010

IBM WebSphere Portal Remote State Service and Fragment Service

Lotus Greenhouse requires its own username and password. Small gremlin...once you log into Files on Greenhouse, you will not be immediately taken to the proper file. You must come back here and click on the "sample code" link again.

Apps RN commented on Mar 19, 2010

IBM WebSphere Portal Remote State Service and Fragment Service

Hi Jan,

I'm not able to download the sample portlets. It is asking for user name and password. When I entered my IBM username/password, it is not accepting it. Could you please provide an alterative link to download the files?