Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Daniel Wilmes
embedded portlet in theme
September 19, 2012 11:36 AM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

Hi there,

we are embedding a portlet in a theme that makes an ajax call. We had it working fine in 6.0.6, but we are upgrading to 6.1.1 and we get this error:

LayoutAction:1019 Reject serveResource

We embed the portlet like this:

$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
$theme.runtime("mydropdown_WAR_myportlet", "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()


Is there something new in liferay 6.1.1 that prevents portlets from being embedded in a theme and make an ajax call?

Thanks,
Daniel
Daniel Wilmes
RE: embedded portlet in theme
September 20, 2012 6:54 AM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

So I have run out of ideas on how to fix the ajax calls for embedded portlets. I have searched the internet, but I have not found any solutions.

I compared the querystring passed into the functions that do the ajax call between 6.1.1 and 6.0.6 and the urls are identical.

I tried using jquery ajax and I still get the same error:

[2012-09-20 09:45:05,081] ERROR [http-bio-8080-exec-106] LayoutAction:1019 Reject serveResource for http://localhost:8080/web/guest/home on portlet_WAR_myPortlet


Javascript below:
 1
 2
 3//JQUERY
 4function myFunction(queryString){
 5    alert(queryString);
 6    jQuery.ajax({
 7    url: queryString,
 8    dataType: "POST",
 9    success: function(data){
10            
11    }
12  });
13}
14
15//ALLOY UI
16function myFunction2(queryString){
17    var A = AUI();
18    var io = A.io.request(queryString, {   
19        dataType : 'json',
20        on: {   
21            success: function(id, obj) {   
22                try{
23                    location.href = this.get('responseData').myVariable;
24                }catch(e){
25                    alert(e);
26                }
27            },
28            failure: function() {   
29                alert('Error.....');   
30            }
31        }
32    });
33}


I added the portlets to page as a normal portlet and the ajax calls worked as expected. I am not sure how to proceed.


Does anyone have suggestions or know of a LPS that deals with this issue? I am using liferay 6.1.1
Daniel Wilmes
RE: embedded portlet in theme
September 20, 2012 7:05 AM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

Seems to be related to this in the javadoc:

 1
 2                            if (!allowAddPortletDefaultResource) {
 3860                                    String url = null;
 4861   
 5862                                    LastPath lastPath = (LastPath)request.getAttribute(
 6863                                            WebKeys.LAST_PATH);
 7864   
 8865                                    if (lastPath != null) {
 9866                                            StringBundler sb = new StringBundler(3);
10867   
11868                                            sb.append(PortalUtil.getPortalURL(request));
12869                                            sb.append(lastPath.getContextPath());
13870                                            sb.append(lastPath.getPath());
14871   
15872                                            url = sb.toString();
16873                                    }
17874                                    else {
18875                                            url = String.valueOf(request.getRequestURI());
19876                                    }
20877   
21878                                    _log.error(
22879                                            "Reject processAction for " + url + " on " +
23880                                                    portlet.getPortletId());
24881   
25882                                    return null;
26883                            }



http://docs.liferay.com/portal/6.1/javadocs-all/src-html/com/liferay/portal/action/LayoutAction.html
Daniel Wilmes
RE: embedded portlet in theme
September 20, 2012 6:36 PM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

We fixed it by doing this:

1. Add <add-default-resource>true</add-default-resource> to each embedded portlet.
2. Add the portlet id to this property in the portal-ext.properties file like below:

portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,myportlet_WAR_portlet
Gabriel Landon
RE: embedded portlet in theme
October 10, 2012 2:18 PM
Answer

Gabriel Landon

Rank: New Member

Posts: 10

Join Date: September 29, 2010

Recent Posts

I did face the same problem.
Thank you very much, you save my day!
Julien POLLY
RE: embedded portlet in theme
October 25, 2012 6:46 AM
Answer

Julien POLLY

Rank: New Member

Posts: 5

Join Date: June 7, 2011

Recent Posts

Daniel Wilmes:
We fixed it by doing this:

1. Add <add-default-resource>true</add-default-resource> to each embedded portlet.
2. Add the portlet id to this property in the portal-ext.properties file like below:

portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,myportlet_WAR_portlet


Thanks for this. It works!
Just to precise something however : don't forget to write in the whitelist the liferay portlets also, otherwise they won't work anymore...
(It was my case and I searched for two hours why!)
Jitendra Rajput
RE: embedded portlet in theme
October 25, 2012 11:12 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 858

Join Date: January 7, 2011

Recent Posts

Daniel Wilmes:
We fixed it by doing this:

1. Add <add-default-resource>true</add-default-resource> to each embedded portlet.
2. Add the portlet id to this property in the portal-ext.properties file like below:

portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,myportlet_WAR_portlet


To add portlet in layout do we need to make this entries in respective files ?
theertha rajeev
RE: embedded portlet in theme
March 21, 2013 5:39 AM
Answer

theertha rajeev

Rank: New Member

Posts: 6

Join Date: March 19, 2013

Recent Posts

We fixed it by doing this:

1. Add <add-default-resource>true</add-default-resource> to each embedded portlet.
2. Add the portlet id to this property in the portal-ext.properties file like below:

portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,myportlet_WAR_portlet




thank u so much..its working in my case also...
Nicolas Tamayo
RE: embedded portlet in theme
March 27, 2013 10:00 AM
Answer

Nicolas Tamayo

Rank: Junior Member

Posts: 29

Join Date: October 3, 2012

Recent Posts

HI!!!!

i developed a portlet that make a custom Login

this portlet is embedded in a velocity template of theme. and i make all process and configurations that you did.

the issue is that when i trying execute the custom login that execute the PortalClassInvoker in order the execute a LoginUtil.login (class that belong to portal-impl.jar) and execute successfully the login. this call not is executed, not show some notice.

this issue only is present when the portlet is embedded in the velocity templeate.

hope you can help me!!
Gabriel Landon
RE: embedded portlet in theme
March 27, 2013 11:50 AM
Answer

Gabriel Landon

Rank: New Member

Posts: 10

Join Date: September 29, 2010

Recent Posts

Nicolas Tamayo:

i developed a portlet that make a custom Login
this portlet is embedded in a velocity template of theme. and i make all process and configurations that you did.
the issue is that when i trying execute the custom login that execute the PortalClassInvoker in order the execute a LoginUtil.login (class that belong to portal-impl.jar) and execute successfully the login. this call not is executed, not show some notice.


I also have a custom login porlet embedded in my theme and have no problem.
Did you follow : http://www.liferay.com/it/community/forums/-/message_boards/message/16008439

1-
MethodKey key = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", HttpServletRequest.class, HttpServletResponse.class, String.class, String.class, boolean.class, String.class);
PortalClassInvoker.invoke(false, key, new Object[] { PortalUtil.getHttpServletRequest(portletRequest), PortalUtil.getHttpServletResponse(portletResponse), username, password, false, null});

2-
session.enable.phishing.protection=false

3-
<private-session-attributes>false</private-session-attributes>
Nicolas Tamayo
RE: embedded portlet in theme
March 27, 2013 12:38 PM
Answer

Nicolas Tamayo

Rank: Junior Member

Posts: 29

Join Date: October 3, 2012

Recent Posts

Thanks Gabriel.

I remembered that i had no specified the false value in the tag "<private-session-attributes>" in the liferay-portlet.xml file. this was the issue with the call LoginUtil.login through to PortalClassInvoker; take affect

Thanks a lot
Leena Ruhela
RE: embedded portlet in theme
September 25, 2014 6:49 PM
Answer

Leena Ruhela

Rank: New Member

Posts: 1

Join Date: November 6, 2013

Recent Posts

Daniel Wilmes:
We fixed it by doing this:

1. Add <add-default-resource>true</add-default-resource> to each embedded portlet.
2. Add the portlet id to this property in the portal-ext.properties file like below:

portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,myportlet_WAR_portlet




Thanks Daniel. I faced the same issue for Liferay 6.2. Your solution worked.