admin管理员组文章数量:1431391
I am making a custom login dialog, similar to the one found on .jsf but i get an error when building:
javax.el.PropertyNotFoundException: /WEB-INF/templates/BasicTemplate.xhtml @58,83 onplete="handleLoginRequest(#{securityController.logIn})": The class 'managedbeans.SecurityController' does not have the property 'logIn'.
I think the mistake is in the way i try to trigger the logging procedure. Could someone have a look if my syntax is correct?
<p:dialog id="dialog" header="Login" widgetVar="dlg" modal="true" width="400" resizable="false" draggable="false" fixedCenter="true">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Em@il: *" />
<p:inputText value="#{securityController.email}"
id="email" required="true" label="email" />
<h:outputLabel for="password" value="Password: * " />
<h:inputSecret value="#{securityController.password}"
id="password" required="true" label="password" />
<f:facet name="footer">
<p:mandButton value="Login" update="growl"
onplete="handleLoginRequest(#{securityController.logIn})"/>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<script type="text/javascript">
function handleLoginRequest(input) {
if(input == false) {
jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
}
}
</script>
And this the managed bean that holds the method that is being called onComplete event:
@ManagedBean
@RequestScoped
public class SecurityController {
@EJB
private IAuthentificationEJB authentificationEJB;
private String email;
private String password;
private String notificationValue;
public void logIn() {
if(authentificationEJB.saveUserState(email, password)) {
notificationValue = "Dobro dosli";
}
}
//getters and setters...
I am making a custom login dialog, similar to the one found on http://www.primefaces/showcase/ui/dialogLogin.jsf but i get an error when building:
javax.el.PropertyNotFoundException: /WEB-INF/templates/BasicTemplate.xhtml @58,83 onplete="handleLoginRequest(#{securityController.logIn})": The class 'managedbeans.SecurityController' does not have the property 'logIn'.
I think the mistake is in the way i try to trigger the logging procedure. Could someone have a look if my syntax is correct?
<p:dialog id="dialog" header="Login" widgetVar="dlg" modal="true" width="400" resizable="false" draggable="false" fixedCenter="true">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Em@il: *" />
<p:inputText value="#{securityController.email}"
id="email" required="true" label="email" />
<h:outputLabel for="password" value="Password: * " />
<h:inputSecret value="#{securityController.password}"
id="password" required="true" label="password" />
<f:facet name="footer">
<p:mandButton value="Login" update="growl"
onplete="handleLoginRequest(#{securityController.logIn})"/>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<script type="text/javascript">
function handleLoginRequest(input) {
if(input == false) {
jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
}
}
</script>
And this the managed bean that holds the method that is being called onComplete event:
@ManagedBean
@RequestScoped
public class SecurityController {
@EJB
private IAuthentificationEJB authentificationEJB;
private String email;
private String password;
private String notificationValue;
public void logIn() {
if(authentificationEJB.saveUserState(email, password)) {
notificationValue = "Dobro dosli";
}
}
//getters and setters...
Share
Improve this question
edited Apr 13, 2011 at 10:25
javing
asked Apr 13, 2011 at 9:42
javingjaving
12.4k37 gold badges141 silver badges213 bronze badges
1
- You can pass the parameter not the method to javascript – niksvp Commented Apr 13, 2011 at 9:50
2 Answers
Reset to default 3You have to call your login method from the actionListener
attribute of p:mandButton
and not inside the onplete
attribute. The javascript function from the example can be used without changes. It is only for displaying the effect.
Change your p:mandButton
this way:
<p:mandButton value="Login" update="growl"
onplete="handleLoginRequest(xhr, status, args)"
actionListener="#{securityController.logIn}"
/>
And use the js function exactly as in the primefaces showcase:
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
}
}
</script>
If you want to execute method on a javascript event then use <a4j:jsfunction>
Example here.
本文标签: javaHow to pass a parameter to a javascript function on a JSF 20 pageStack Overflow
版权声明:本文标题:java - How to pass a parameter to a javascript function on a JSF 2.0 page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745571877a2664095.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论