Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Liferay.Address is undefined for anonymous user Alexey Kakunin May 23, 2010 12:27 PM
RE: Liferay.Address is undefined for anonymous user Alexey Kakunin May 23, 2010 12:54 PM
RE: Liferay.Address is undefined for anonymous user Carlos Llongo August 4, 2010 4:54 AM
RE: Liferay.Address is undefined for anonymous user Alexey Kakunin August 4, 2010 12:44 PM
RE: Liferay.Address is undefined for anonymous user Carlos Llongo August 5, 2010 3:27 AM
RE: Liferay.Address is undefined for anonymous user Viktor Palai November 5, 2010 2:33 AM
RE: Liferay.Address is undefined for anonymous user Corentin R May 2, 2011 9:32 AM
RE: Liferay.Address is undefined for anonymous user Corentin R May 3, 2011 1:04 AM
RE: Liferay.Address is undefined for anonymous user Tanweer . May 15, 2011 10:29 AM
RE: Liferay.Address is undefined for anonymous user Corentin R May 15, 2011 12:03 PM
RE: Liferay.Address is undefined for anonymous user Tanweer . May 16, 2011 10:48 AM
RE: Liferay.Address is undefined for anonymous user Corentin R May 17, 2011 2:23 AM
RE: Liferay.Address is undefined for anonymous user Carl Spangenberger March 27, 2012 7:05 AM
RE: Liferay.Address is undefined for anonymous user Corentin R March 28, 2012 3:31 AM
RE: Liferay.Address is undefined for anonymous user Carl Spangenberger March 28, 2012 10:45 AM
RE: Liferay.Address is undefined for anonymous user Mayur Patel May 17, 2012 7:20 AM
RE: Liferay.Address is undefined for anonymous user Michele Giacobazzi December 6, 2012 7:44 AM
RE: Liferay.Address is undefined for anonymous user Michele Giacobazzi December 10, 2012 10:09 AM
RE: Liferay.Address is undefined for anonymous user Jan Geißler December 11, 2012 1:26 AM
Alexey Kakunin
Liferay.Address is undefined for anonymous user
May 23, 2010 12:27 PM
Answer

Alexey Kakunin

Rank: Expert

Posts: 376

Join Date: July 7, 2008

Recent Posts

Hi!

I'm trying to implement own registration in plugin env and during registration ask user for address. I'm using Liferay.DynamicSelect for selecting country and region (for selected country) and code looks like:
 1
 2<%
 3themeDisplay.setIncludeServiceJs(true); // to enable dynamic selectors
 4%>
 5
 6<aui:script use="liferay-dynamic-select">
 7    new Liferay.DynamicSelect(
 8        [
 9            {
10                select: "<portlet:namespace />billing-countryId",
11                selectId: "countryId",
12                selectDesc: "name",
13                selectVal: "<%= address != null ? address.getCountryId() : 13 %>",
14                selectData: Liferay.Address.getCountries
15            },
16            {
17                select: "<portlet:namespace />billing-regionId",
18                selectId: "regionId",
19                selectDesc: "name",
20                selectVal: "<%= address != null ? address.getRegionId() : 0 %>",
21                selectData: Liferay.Address.getRegions
22            }
23        ]
24    );


Everything works fine for registered user, but for anonymous (this portlet should be used by anonymous) I've got javascript error in browser:
1
2Uncaught TypeError: Cannot read property 'getCountries' of undefined


Does I missed something to enable usage of Liferay services via JS for anonymous user?

==
Alexey Kakunin
EmForge: Liferay Based Project Hosting Service
Alexey Kakunin
RE: Liferay.Address is undefined for anonymous user
May 23, 2010 12:54 PM
Answer

Alexey Kakunin

Rank: Expert

Posts: 376

Join Date: July 7, 2008

Recent Posts

OK, found
I need to move /liferay/address.js from javascript.everything.files to the javascript.barebone.files

Unfortunatelly these properties not supported via portlets hook, so, only possible change them via ext (but good thing - ext environment in 6 managed from same plugins)

==
Alexey Kakunin
EmForge: Liferay Based Project Hosting Service
Carlos Llongo
RE: Liferay.Address is undefined for anonymous user
August 4, 2010 4:54 AM
Answer

Carlos Llongo

Rank: New Member

Posts: 10

Join Date: March 10, 2010

Recent Posts

Hi Alexey,

I have a similar problem. As a registered user, the country list is populated, but for anonymous users it's empty.

I tried moving address.js from "everything" to "barebone" but the problem persisted.

I then moved all the js used in the page to "barebone", but not luck either with that.

Any idea what the problem can be?

Thanks!
Alexey Kakunin
RE: Liferay.Address is undefined for anonymous user
August 4, 2010 12:44 PM
Answer

Alexey Kakunin

Rank: Expert

Posts: 376

Join Date: July 7, 2008

Recent Posts

Hi Carlos
In my case it was enough. Liferay use caching very agressively.
probably it is cashed barebone.js somethere
Try to clean /tmp/liferay or ${tomcat}/tmp/liferay folders


==
Alexey Kakunin
EmForge: Liferay Based Project Hosting Service
Carlos Llongo
RE: Liferay.Address is undefined for anonymous user
August 5, 2010 3:27 AM
Answer

Carlos Llongo

Rank: New Member

Posts: 10

Join Date: March 10, 2010

Recent Posts

Hi Alexey,

I tried cleaning those folders but the problem persists.

I have been reading lots of documentation and most agree that most Liferay services require the user to be logged in to work. That would explain why the select is populated if the user is logged in, but it's not when it's an anonymous user.

¿You where able to populate the select with an anonymous user?

Thanks!
Viktor Palai
RE: Liferay.Address is undefined for anonymous user
November 5, 2010 2:33 AM
Answer

Viktor Palai

Rank: New Member

Posts: 20

Join Date: October 14, 2010

Recent Posts

Hi Carlos,

have you been able to fix this issue?

Im having the same problem that I cant display list of Countries on the create_account page even I did all the suggested steps.

Please help me if you can.

Thank you
Corentin R
RE: Liferay.Address is undefined for anonymous user
May 2, 2011 9:32 AM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Hi,
I'm facing exactly the same problem. I'm trying to use the Liferay.DynamicSelect on liferay's create_account.jsp.
To do so I tryed to add js librairies to barbone but I'm still getting this message from Firebug AUI().io.request is not a function
I tryed to add the Alloyui io librairies to barebone but it seems not to change anything since I'm still getting exactly the same output from Firebug...
1aui/aui-base/aui-base.js,\
2        aui/aui-io/aui-io.js,\
3        aui/aui-io/aui-io-request.js,\
4        aui/aui-io/aui-io-plugin.js,\

Looks like I'm missing some Js librairies ? But which one ?
Corentin R
RE: Liferay.Address is undefined for anonymous user
May 3, 2011 1:04 AM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Found it !
In my case I have to add liferay/address.js to barebone via portla-ext.properties and then use the following code to use it. Pay attention to the aui-io-request library that must be specified in the use attribute of aui:script when displayed on guest pages (on authenticated pages it seems to work even without it).
 1<aui:script use="liferay-dynamic-select,[color=#ff0000]aui-io-request[/color]">
 2                        new Liferay.DynamicSelect(
 3                            [
 4                                {
 5                                    select: '<portlet:namespace />addressCountryId',
 6                                    selectData: Liferay.Address.getCountries,
 7                                    selectDesc: 'name',
 8                                    selectId: 'countryId',
 9                                    selectVal: ''
10                                },
11                                {
12                                    select: '<portlet:namespace />addressRegionId',
13                                    selectData: Liferay.Address.getRegions,
14                                    selectDesc: 'name',
15                                    selectId: 'regionId',
16                                    selectVal: ''
17                                }
18                            ]
19                        );
20            </aui:script>
Tanweer .
RE: Liferay.Address is undefined for anonymous user
May 15, 2011 10:29 AM
Answer

Tanweer .

Rank: Expert

Posts: 319

Join Date: March 11, 2010

Recent Posts

Hi Coretin,

I am trying to implement the Dynamic Select for Country > Region.
For a logged in user, it works perfectly fine. But for guests/unregistered users, it doesn't work.I tried following your solution, but even that doesn't work for me.It seems you have got it working for the guest user.Can you share the code or provide some solution?

Any help is Appreciated.

Regards,
Tanweer Ahmed Ansari,
mPowerian-BoschLer
Corentin R
RE: Liferay.Address is undefined for anonymous user
May 15, 2011 12:03 PM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Hi !
If it's working for your authenticated user only that may be because you didn't add liferay/address.js to barebone in your portal-ext.properties ...
Have you got an javascript error when the page is loading ?

Corentin.
Tanweer .
RE: Liferay.Address is undefined for anonymous user
May 16, 2011 10:48 AM
Answer

Tanweer .

Rank: Expert

Posts: 319

Join Date: March 11, 2010

Recent Posts

Corentin R:
Hi !
If it's working for your authenticated user only that may be because you didn't add liferay/address.js to barebone in your portal-ext.properties ...
Have you got an javascript error when the page is loading ?

Corentin.


Coretin,

I have already added liferay/address.js to barebone through portal-ext.But even that doesn't help.Wel I do not get any js error in browser.
Can you share your exact implemented code ?

Regards,
Tanweer Ahmed Ansari,
mPowerian-BoschLer
Corentin R
RE: Liferay.Address is undefined for anonymous user
May 17, 2011 2:23 AM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Hello,
Hummm ... what else can I add emoticon
Did you insert
1themeDisplay.setIncludeServiceJs(true);
in the top of your jsp ?

Here is my portal-ext.properties :
 1javascript.barebone.files=\
 2        \
 3        #
 4        # YUI core
 5        #
 6        \
 7        aui/yui/yui.js,\
 8        \
 9        #
10        # YUI modules
11        #
12        \
13        aui/attribute/attribute.js,\
14        aui/event-custom/event-custom.js,\
15        aui/loader/loader.js,\
16        aui/oop/oop.js,\
17        \
18        #
19        # Alloy core
20        #
21        \
22        aui/aui-base/aui-base.js,\
23        \
24        #
25        # Liferay module definitions
26        #
27        \
28        liferay/modules.js,\
29        liferay/address.js,\
30        \
31        #
32        # Liferay base utility scripts
33        #
34        \
35        liferay/dependency.js,\
36        liferay/language.js,\
37        liferay/liferay.js,\
38        liferay/util.js,\
39        \
40        #
41        # Liferay utility scripts
42        #
43        \
44        liferay/events.js,\
45        liferay/portal.js,\
46        liferay/portlet.js,\
47        liferay/dynamic_select.js,\
48        liferay/portlet_sharing.js

Hope it will help you solve your problem.
Corentin
Carl Spangenberger
RE: Liferay.Address is undefined for anonymous user
March 27, 2012 7:05 AM
Answer

Carl Spangenberger

Rank: New Member

Posts: 2

Join Date: February 24, 2012

Recent Posts

I am having same problem with Liferay 6.1 EE GA. Trying to get country and region using liferay-dynamic-select but does not work.
This is my test page for create_account.jsp hook. do not get error, but does not load the Lifreray.Address.countries or Licrary,Address.regions in the page.What am I doing incorrectly? I look at the javascript in firebug and the Address class is there and the javascript is executing.

Thanks,

Carl

<%--
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<script src="/html/js/liferay/service.js" type="text/javascript"> </script>


<%@ include file="/html/portlet/login/init.jsp" %>



<%
themeDisplay.setIncludeServiceJs(true);
String redirect = ParamUtil.getString(request, "redirect");

String openId = ParamUtil.getString(request, "openId");

PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil.getDefaultPasswordPolicy(company.getCompanyId());

Calendar birthday = CalendarFactoryUtil.getCalendar();

birthday.set(Calendar.MONTH, Calendar.JANUARY);
birthday.set(Calendar.DATE, 1);
birthday.set(Calendar.YEAR, 1970);

boolean male = ParamUtil.getBoolean(request, "male", true);
%>



<portlet:actionURL var="createAccoutURL">
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/login/create_account" />
</portlet:actionURL>

<aui:form action="<%= createAccoutURL %>" method="post" name="fm">
<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.ADD %>" />
<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
<aui:input name="openId" type="hidden" value="<%= openId %>" />

<liferay-ui:error exception="<%= AddressCityException.class %>" message="please-enter-a-valid-city" />
<liferay-ui:error exception="<%= AddressStreetException.class %>" message="please-enter-a-valid-street" />
<liferay-ui:error exception="<%= AddressZipException.class %>" message="please-enter-a-valid-postal-code" />
<liferay-ui:error exception="<%= CaptchaMaxChallengesException.class %>" message="maximum-number-of-captcha-attempts-exceeded" />
<liferay-ui:error exception="<%= CaptchaTextException.class %>" message="text-verification-failed" />
<liferay-ui:error exception="<%= CompanyMaxUsersException.class %>" message="unable-to-create-user-account-because-the-maximum-number-of-users-has-been-reached" />
<liferay-ui:error exception="<%= ContactFirstNameException.class %>" message="please-enter-a-valid-first-name" />
<liferay-ui:error exception="<%= ContactFullNameException.class %>" message="please-enter-a-valid-first-middle-and-last-name" />
<liferay-ui:error exception="<%= ContactLastNameException.class %>" message="please-enter-a-valid-last-name" />
<liferay-ui:error exception="<%= DuplicateUserEmailAddressException.class %>" message="the-email-address-you-requested-is-already-taken" />
<liferay-ui:error exception="<%= DuplicateUserIdException.class %>" message="the-user-id-you-requested-is-already-taken" />
<liferay-ui:error exception="<%= DuplicateUserScreenNameException.class %>" message="the-screen-name-you-requested-is-already-taken" />
<liferay-ui:error exception="<%= EmailAddressException.class %>" message="please-enter-a-valid-email-address" />
<liferay-ui:error exception="<%= NoSuchCountryException.class %>" message="please-select-a-country" />
<liferay-ui:error exception="<%= NoSuchListTypeException.class %>" message="please-select-a-type" />
<liferay-ui:error exception="<%= NoSuchRegionException.class %>" message="please-select-a-region" />
<liferay-ui:error exception="<%= PhoneNumberException.class %>" message="please-enter-a-valid-phone-number" />
<liferay-ui:error exception="<%= RequiredFieldException.class %>" message="please-fill-out-all-required-fields" />
<liferay-ui:error exception="<%= ReservedUserEmailAddressException.class %>" message="the-email-address-you-requested-is-reserved" />
<liferay-ui:error exception="<%= ReservedUserIdException.class %>" message="the-user-id-you-requested-is-reserved" />
<liferay-ui:error exception="<%= ReservedUserScreenNameException.class %>" message="the-screen-name-you-requested-is-reserved" />
<liferay-ui:error exception="<%= TermsOfUseException.class %>" message="you-must-agree-to-the-terms-of-use" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" message="please-enter-a-valid-email-address" />
<liferay-ui:error exception="<%= UserIdException.class %>" message="please-enter-a-valid-user-id" />

<liferay-ui:error exception="<%= UserPasswordException.class %>">

<%
UserPasswordException upe = (UserPasswordException)errorException;
%>

<c:if test="<%= upe.getType() == UserPasswordException.PASSWORD_CONTAINS_TRIVIAL_WORDS %>">
<liferay-ui:message key="that-password-uses-common-words-please-enter-in-a-password-that-is-harder-to-guess-i-e-contains-a-mix-of-numbers-and-letters" />
</c:if>

<c:if test="<%= upe.getType() == UserPasswordException.PASSWORD_INVALID %>">
<liferay-ui:message key="that-password-is-invalid-please-enter-in-a-different-password" />
</c:if>

<c:if test="<%= upe.getType() == UserPasswordException.PASSWORD_LENGTH %>">
<%= LanguageUtil.format(pageContext, "that-password-is-too-short-or-too-long-please-make-sure-your-password-is-between-x-and-512-characters", String.valueOf(passwordPolicy.getMinLength()), false) %>
</c:if>

<c:if test="<%= upe.getType() == UserPasswordException.PASSWORD_TOO_TRIVIAL %>">
<liferay-ui:message key="that-password-is-too-trivial" />
</c:if>

<c:if test="<%= upe.getType() == UserPasswordException.PASSWORDS_DO_NOT_MATCH %>">
<liferay-ui:message key="the-passwords-you-entered-do-not-match-each-other-please-re-enter-your-password" />
</c:if>
</liferay-ui:error>

<liferay-ui:error exception="<%= UserScreenNameException.class %>" message="please-enter-a-valid-screen-name" />
<liferay-ui:error exception="<%= WebsiteURLException.class %>" message="please-enter-a-valid-url" />
<aui:model-context bean="address" model="<%= Address.class %>" />
<div class="lfr-form-row">
<div class="row-fields">
<aui:column columnWidth="50">
<aui:input name="addressId" type="hidden" value="" />

<aui:select label="country" name="addressCountryId" />

<aui:select label="region" name="addressRegionId" />
</aui:column>
</div>
</div>

<aui:script use="liferay-dynamic-select,aui-io-request">


new Liferay.DynamicSelect(
[
{
select: '<portlet:namespace />addressCountryId',
selectData: Liferay.Address.getCountries,
selectDesc: 'name',
selectId: 'countryId',
selectVal: ''
},
{
select: '<portlet:namespace />addressRegionId',
selectData: Liferay.Address.getRegions,
selectDesc: 'name',
selectId: 'regionId',
selectVal: ''
}
]
);
</aui:script>

</aui:form>



<liferay-util:include page="/html/portlet/login/navigation.jsp" />

<c:if test="<%= windowState.equals(WindowState.MAXIMIZED) %>">
<aui:script>
Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace />firstName);
</aui:script>
</c:if>
Corentin R
RE: Liferay.Address is undefined for anonymous user
March 28, 2012 3:31 AM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Hi Carl,

Did you add liferay/address.js to the barebone in your portal-ext.properties?
Liferay.Address isn't load by default for unauthenticated users...
Carl Spangenberger
RE: Liferay.Address is undefined for anonymous user
March 28, 2012 10:45 AM
Answer

Carl Spangenberger

Rank: New Member

Posts: 2

Join Date: February 24, 2012

Recent Posts

Corentin R:
Hi Carl,

Did you add liferay/address.js to the barebone in your portal-ext.properties?
Liferay.Address isn't load by default for unauthenticated users...



This is my protal.ext.properties file.

redirect.url.security.mode=ip
redirect.url.domains.allowed=
redirect.url.ips.allowed=127.0.0.1,192.168.1.82
dl.file.max.size=100000000

javascript.barebone.files=\
\
#
# YUI core
#
\
aui/yui/yui.js,\
\
#
# YUI modules
#
\
aui/attribute/attribute.js,\
aui/event-custom/event-custom.js,\
aui/loader/loader.js,\
aui/oop/oop.js,\
\
#
# Alloy core
#
\
aui/aui-base/aui-base.js,\
\
#
# Liferay module definitions
#
\
liferay/modules.js,\
liferay/address.js,\
#
# Liferay base utility scripts
#
\
liferay/dependency.js,\
liferay/language.js,\
liferay/liferay.js,\
liferay/util.js,\
\
#
# Liferay utility scripts
#
\
liferay/events.js,\
liferay/portal.js,\
liferay/portlet.js,\
liferay/dynamic_select.js,\
liferay/portlet_sharing.js

javascript.barebone.enabled=true
auth.pipeline.enable.liferay.check=false.

The file Liferay,Adress class is in the DOM when look at it through firebug.

Thanks for the help

Carl
Mayur Patel
RE: Liferay.Address is undefined for anonymous user
May 17, 2012 7:20 AM
Answer

Mayur Patel

Rank: Expert

Posts: 342

Join Date: November 17, 2010

Recent Posts

In LF 6.1 error was coming for aui-io-request after adding same in aui:script mentioned by Corentin. It worked perfectly fine

Thanks a lot Corentin for the solution, Its really helpful emoticon
Michele Giacobazzi
RE: Liferay.Address is undefined for anonymous user
December 6, 2012 7:44 AM
Answer

Michele Giacobazzi

Rank: Junior Member

Posts: 37

Join Date: September 9, 2011

Recent Posts

Hi,
I implemented a login page with address required in Liferay 6.0.6 and ported it succesfully to 6.1.0.

Problems started with 6.1.1.

Now I have a problem with Liferay.Address.getCountries, but of a different kind.

The object is present in the JS console, and I can execute the query. But I receive the following exception as JSON answer:

Object {exception: "Please sign in to invoke this method"}


Obviously the user can't sign in because it does not exist yet.

Is there a workaround?
Michele Giacobazzi
RE: Liferay.Address is undefined for anonymous user
December 10, 2012 10:09 AM
Answer

Michele Giacobazzi

Rank: Junior Member

Posts: 37

Join Date: September 9, 2011

Recent Posts

To make getCountries and getRegions work for unregistered user you have to add the following two lines in porta-ext.properties:

1
2#allow json access to some methods even if not logged
3json.service.public.methods=getCountries,getRegions
4jsonws.web.service.public.methods=getCountries,getReqions


The same for other methods you might need to call.
Jan Geißler
RE: Liferay.Address is undefined for anonymous user
December 11, 2012 1:26 AM
Answer

Jan Geißler

Community Moderator

Rank: Liferay Master

Posts: 533

Join Date: July 5, 2011

Recent Posts

Does this work for custom Webservices as well?