Foren

html form values are not able to get in backing bean(JSF)

john john, geändert vor 11 Jahren.

html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Hi ,

I have created JSF Login portlet in liferay6.1.1 ga2.

I am facing one strange problem.i am unable to get values in loginbackingbean.

i have binded the input component as below.

<h:inputText id="handle" value="#{loginModelBean.handle}" required="true" validatorMessage="#{i18n['you-have-entered-invalid-data']}">
<f:ajax render="handleMessage" />
<c:if test="#{loginBackingBean.handleLabel == 'email-address'}">
<f:validateRegex pattern=".+[@].+[.].+" />
</c:if>
</h:inputText>

I have injected loginmodelbean in loginbackingbean as below.

// Injections
@ManagedProperty(value = "#{loginModelBean}")
private LoginModelBean loginModelBean;


when i try to get the input value in loginbacking bean it is giving null.

loginModelBean.getHandle() returns null..

Please help how to get resolved this issue
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Neil just posted a JSF version of a login portlet. I'd grab his copy and see how he's handling the login stuff. It might be a better foundation to build your own logic upon anyway, especially if you started from scratch...
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
David's advice is very good -- starting with the jsf2-login-portlet might be best because you would be starting with a working example.
john john, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Hi neil,

thanks for your replay.i have taken your example and it is working fine for me..there is one more problem i am facing..once login i need to regirect to my own page ..i am new to life ray..could you please guide me how to do this..i tried to hard code redirect as /web/guest which is not working...

regards
john
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
In the LoginBackingBean.authenticate() method, there are some calls to externalContext.redirect(String) which you should be able to customize according to your requirements.
john john, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Hi Neil,

Thanks for your information..It's really Usefull but unfortunately i am not able to get the session.

even though the following line returns true..

PortalClassInvoker.invoke(false, LOGIN_UTIL_FQCN, LOGIN_METHOD, LOGIN_PARAM_TYPES, httpServletRequest, httpServletResponse,
"test@liferay.com", "test", rememberMe, authType);
authenticated = true;
System.out.println("i am in authenticated:authenticated" + authenticated);

However when i tried to display the logged in user information in redirect page is returning false..

the following line in my Page is returning false..

<h:outputText value="#{liferay.themeDisplay.signedIn}"/>

is there any steps to follow for maintaining the session...

Thanks in advance..
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Does the unmodified jsf2-login-portlet work for you? If so then that's good -- it would help us figure out how to fix your code. Otherwise, if it doesn't work for you, then maybe there is something different about how your servlet-container/app-server handles sessions. Are you using Liferay Portal 6.1.1-ce-ga2 and Tomcat 7?
john john, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Hi Neil,

thanks for your replay...Yes i am using the same code (6.1.1 ga2) but i have deployed in weblogic 10.3.5


Thanks in advance
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
When you wrote:

Yes i am using the same code


Do you mean that you have tried the unmodified jsf2-login-portlet with weblogic 10.3.5 and it doesn't work?
john john, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Hi Neil,

I am using the same JSF Login Portlet Code from Github .

After authentication i am forwarding to a new page where i am checking weathter the user is signed or not using themedisplay.isSignedIn which is returning false.
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Does it work in WebLogic if you do not add your redirect code?
john john, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Yes am able to login .tested on the following platform

Is:windows 7

Application server:oracle weblogic 10.3.5
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
OK, when you get a chance, I would recommend add your redirect code, and then deploy the portlet to Tomcat. If it works in Tomcat, then it might be a WebLogic issue that you are encountering. If it does not work in Tomcat, then it might be a bug in your redirect code.
john john, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 23 Beitrittsdatum: 17.12.12 Neueste Beiträge
Hi Neil,

Thanks for your replay....Even in Tomcat i am getting the same problem..

I have changed the authenticate method .the code as follows




String toViewId="";

System.out.println("i am in authenticate");
final LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
final ActionRequest actionRequest = (ActionRequest) liferayFacesContext.getPortletRequest();
final ActionResponse actionResponse = (ActionResponse) liferayFacesContext.getPortletResponse();
final ThemeDisplay themeDisplay = liferayFacesContext.getThemeDisplay();
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(actionRequest);

// If the request object is a wrapper that handles special namespacing considerations for portlet session
// attributes, then get the inner-most wrapped request. This will ensure that the following call to
// LoginUtil.login(...) will be able to work with a session that has an attribute map shared by the portal.
if (httpServletRequest.getClass().getName().equals(NAMESPACE_SERVLET_REQUEST_FQCN)) {

while (httpServletRequest instanceof HttpServletRequestWrapper) {
final HttpServletRequestWrapper httpServletRequestWrapper = (HttpServletRequestWrapper) httpServletRequest;
httpServletRequest = (HttpServletRequest) httpServletRequestWrapper.getRequest();
}
}

final HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(actionResponse);
System.out.println("hanlde"+loginModelBean.getHandle());
System.out.println("password"+loginModelBean.getPassword());

final boolean rememberMe = loginModelBean.isRememberMe();

boolean authenticated = false;
String feedbackMessageId = null;

try {
PortalClassInvoker.invoke(false, LOGIN_UTIL_FQCN, LOGIN_METHOD, LOGIN_PARAM_TYPES, httpServletRequest, httpServletResponse,
"sivasumathi1030@gmail.com", "test1", rememberMe, authType);
authenticated = true;

System.out.println("i am in authenticated:authenticated" + authenticated);
} catch (final AuthException e) {
feedbackMessageId = "authentication-failed";
} catch (final CompanyMaxUsersException e) {
feedbackMessageId = "unable-to-login-because-the-maximum-number-of-users-has-been-reached";
} catch (final CookieNotSupportedException e) {
feedbackMessageId = "authentication-failed-please-enable-browser-cookies";
} catch (final NoSuchUserException e) {
feedbackMessageId = "authentication-failed";
} catch (final PasswordExpiredException e) {
feedbackMessageId = "your-password-has-expired";
} catch (final UserEmailAddressException e) {
feedbackMessageId = "authentication-failed";
} catch (final UserLockoutException e) {
feedbackMessageId = "this-account-has-been-locked";
} catch (final UserPasswordException e) {
feedbackMessageId = "authentication-failed";
} catch (final UserScreenNameException e) {
feedbackMessageId = "authentication-failed";
} catch (final Exception e) {
logger.error(e);
}

if (authenticated) {

toViewId="Success";
} else {

if (feedbackMessageId != null) {
liferayFacesContext.addGlobalErrorMessage(feedbackMessageId);
toViewId=null;
}
}
return toViewId;
}

In FacesConfig i am redirecting toViewid to separate page where i am testing liferay.themedisplay.isSignedin which is returning false..

Thanks in Advance..
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
In FacesConfig i am redirecting toViewid to separate page where i am testing liferay.themedisplay.isSignedin which is returning false..


OK, I see that you have changed the authenticate() method so that it returns a String, and I am assuming you are using a navigation-rule with a <redirect/> inside of the WEB-INF/faces-config.xml descriptor? That would be a very nice consistent JSF way of doing things, and I commend you for that approach. But it might be the case, then the redirect requirements of JSR 329 (the JCP Standard implemented by Liferay Faces Bridge) *might* be incompatible with the login use-case of Liferay Portal. Just a guess, I don't know for sure.

If you call externalContext.redirect(url) from the authenticate() method (which is what the jsf2-login-portlet demo does), then do things start working?
jon miran, geändert vor 10 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 3 Beitrittsdatum: 02.10.12 Neueste Beiträge
Hi, i have the same problem .
I'am working with: Liferay-portal-6.1.1-ce-ga2 ,glassfish 3.1.2, jsf 2.13-b02 and liferay-faces-bridge-3.1.0-rc2.

I download the jsf2 login portlet and deployed it. when i press the submit button , the authenticate() method works fine but the redirect show me an exception ( bridge exception: IleagalStateException) and the page shows me that an error occurred when accessing the resource. if i do refresh for this page the same error still showing.
When i examine the resulting url, it has 1 as value of the parameter p_p_lifecycle , so i modified it to 0 in this url and do refresh, and it works.
is there a way to set this parameter to 0 when redirecting?

Please help how to get resolved this issue.
thumbnail
Vernon Singleton, geändert vor 10 Jahren.

RE: html form values are not able to get in backing bean(JSF)

Expert Beiträge: 315 Beitrittsdatum: 14.01.13 Neueste Beiträge
Hi Jon,

Could you post

0) the xhtml pages showing the call to redirect
1) the backing code for your redirect
2) the relavent part of your faces config.
3) the full error message you receive when your redirect fires

I will take a look at it.

- Vernon
jon miran, geändert vor 10 Jahren.

RE: html form values are not able to get in backing bean(JSF)

New Member Beiträge: 3 Beitrittsdatum: 02.10.12 Neueste Beiträge
Hi Vernon,
Thanks for your reply...
I solved the problem and i think that it was an issue in the liferay-faces-*-3.1.0-rc2.
So, i download the 5 files (liferay-faces-bridge-impl-3.1.1-ga2, liferay-faces-bridge-api-3.1.1-ga2, liferay-faces-alloy-3.1.1-ga2, liferay-faces-portal-3.1.1-ga2, liferay-faces-util-3.1.1-ga2) and replace them with the old files and it works .emoticon

But there is another thing, this login portlet code need the 2 classes liferay.portal.util.PropValues and liferay.portal.util.WebKeys, which exist in the portal-impl.jar.
when i put this jar in the portlet, a new error has been shown "log4j ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender" , so i remove the portal-impl.jar, download the source code of these classes (PropValues and WebKeys) and add them to the portlet. Is there another method to fix this up?

regards
Jon
thumbnail
Vernon Singleton, geändert vor 10 Jahren.

Re: [Liferay Forums][Liferay Faces - English] RE: html form values are not

Expert Beiträge: 315 Beitrittsdatum: 14.01.13 Neueste Beiträge
Glad to hear that your problem got solved.

sent from a blackberry

-----Original Message-----
From: "jon miran from liferay.com" <forums@liferay.com>
Date: Thu, 11 Apr 2013 07:47:22
To: forums@liferay.com<forums@liferay.com>
Reply-To: "forums@liferay.com" <forums@liferay.com>
Subject: [Liferay Forums][Liferay Faces - English] RE: html form values are
not able to get in backing bean(JSF)



Hi Vernon,
Thanks for your replay...
I solved the problem and i think that it's an issue in the liferay-faces-*-3.1.0-rc2.
I download the 5 files (liferay-faces-bridge-impl-3.1.1-ga2, liferay-faces-bridge-api-3.1.1-ga2, liferay-faces-alloy-3.1.1-ga2, liferay-faces-portal-3.1.1-ga2, liferay-faces-util-3.1.1-ga2) and replace them with the old one and it works . emoticon <@theme_images_path@/emoticons/laugh.gif>

regards

To view the thread, follow the link below:
https://www.liferay.com/community/forums/-/message_boards/view_message/23536004
--
Thanks, Liferay.com Forums <http://http://www.liferay.com>
thumbnail
Neil Griffin, geändert vor 10 Jahren.

RE: Re: [Liferay Forums][Liferay Faces - English] RE: html form values are

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
If you look at LoginBackingBean.java you will see the following imports:

import com.liferay.portal.util.PropsValues;
import com.liferay.portal.util.WebKeys;


You're right -- the constants needed in those classes are found in portal-impl.jar so to get around that problem the constants were copied directly into the portlet: