Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
L F
Link beetween 2 portlet
April 29, 2008 6:11 AM
Answer

L F

Rank: New Member

Posts: 4

Join Date: April 29, 2008

Recent Posts

Hi,


I have a first portlet (portlet_1) which contain 1 html link with parameters : like <a href="the_url_i_need_to_find/mylink?param1=test">link</a>

When i click on this link, i need to access to a second portlet (portlet_2); the portlet_2 has to display some informations in function of the parameter which is pass in the link.

I don't have any ideas about how to do that ... which url i have to put in my link in the portlet_1 to have an access to the portlet_2 ...

Any help is welcome.

Thanks very much :-)



Loïc
Mika Koivisto
RE: Link beetween 2 portlet
April 29, 2008 6:23 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1501

Join Date: August 7, 2006

Recent Posts

You can target parameters to another portlet by prefixing them with the portlet namespace. For instance if I had a portlet named portlet1 in a war in context test and I wanted to target parameter param1 to it from another portlet I could create a url like this:

1<a href="/page_friendly_url?_portlet1_WAR_test_param1=value">Test</a>
L F
RE: Link beetween 2 portlet
April 30, 2008 12:41 AM
Answer

L F

Rank: New Member

Posts: 4

Join Date: April 29, 2008

Recent Posts

Hello,

Thank you very much for your answer.

I think i don't understand something :

When i see in the database (table portletpreferences), i see this name (portletId column) for my portlets :

Display_Docs_WAR_DisplayDocsPortlet
Menu_WAR_MenuPortlet


So in my portlet Menu , i make a link in the view.jsp file like this :

<a href="/page_friendly_url?_Display_Docs_WAR_DisplayDocsPortlet_param1=toto">Test</a>
or like this
<a href="/page_friendly_url?Display_Docs_WAR_DisplayDocsPortlet_param1=toto">Test</a>
I try the both because i don't know if the first _ is important

and in my portlet DisplayDocs , in the view.jsp file i write that :

<%
String test = ParamUtil.getString(request, "param1");
out.print("<br/>*"+test+"*");
%>

Questions and problems :
1°/ what the page_friendly_url ? i don't understand what i have to write here , when i click i just want to modifie the content of the DisplayDocs portlet
2°/ What the good url attributes : _Display_Docs_WAR_DisplayDocsPortlet_param1=value or Display_Docs_WAR_DisplayDocsPortlet_param1=value , is the first _ important ?
3°/ The result in my portlet DisplayDocs is **, i don't have the param1 value (toto)


Thanks you very very much for your help :-)


Mika Koivisto:
You can target parameters to another portlet by prefixing them with the portlet namespace. For instance if I had a portlet named portlet1 in a war in context test and I wanted to target parameter param1 to it from another portlet I could create a url like this:

1<a href="/page_friendly_url?_portlet1_WAR_test_param1=value">Test</a>
Jörn Ebeling
RE: Link beetween 2 portlet
April 30, 2008 12:51 AM
Answer

Jörn Ebeling

Rank: Regular Member

Posts: 119

Join Date: January 5, 2006

Recent Posts

Are you using struts-portlets?
If so, you have to enable GET-Parameters by adding
1
2protected boolean isCheckMethodOnProcessAction() {
3    return _CHECK_METHOD_ON_PROCESS_ACTION;
4}
5
6private static final boolean _CHECK_METHOD_ON_PROCESS_ACTION = false;


to your ViewAction
Mika Koivisto
RE: Link beetween 2 portlet
April 30, 2008 12:55 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1501

Join Date: August 7, 2006

Recent Posts

L F:
So in my portlet Menu , i make a link in the view.jsp file like this :

<a href="/page_friendly_url?_Display_Docs_WAR_DisplayDocsPortlet_param1=toto">Test</a>
or like this
<a href="/page_friendly_url?Display_Docs_WAR_DisplayDocsPortlet_param1=toto">Test</a>
I try the both because i don't know if the first _ is important


The first underscore (_) is important and needed.
L F
RE: Link beetween 2 portlet
May 6, 2008 8:03 AM
Answer

L F

Rank: New Member

Posts: 4

Join Date: April 29, 2008

Recent Posts

First thanks for your help :-)

I think i'm a noob with this problem of link :'/.

so, my application :

1°/
1 struts portlet with a view and an edit page.

with this link in the view.jsp :

<portlet:actionURL var="TestLoicURL">
<portlet:param name="struts_action" value="/library/edit_entry" />
<portlet:param name="bookId" value="2" />
</portlet:actionURL>
<a href='<%= TestLoicURL.toString() %>'>test edit</a>

it's ok when i click, i can see the parameter bookId in the edit Action and in the edit.jsp

2°/
Another portlet (jsp portlet)

if i try that in my JSP portlet:

<a href="/page_friendly_url?_library_portlet_WAR_struts_portlet_test_bookId=3">Test</a>

(library_portlet_WAR_struts_portlet_test is the portletId in the table portletpreferences)

and if i try to display the bookId param (3) in the jsp of my struts portlet, noting is display.

Questions :
i) Why can't i display my bookId parameter, do i miss something ?
ii) I don't understant what i have to put in this url to replace page_friendly_url (with this url it's quit long to display the screen)
iii) Is it possible to specify which action in the struts portlet i wan't to access (for example my EditAction) ?

Thank you very much :-)