jsf 2.2 - Using Glassfish JDBC realm with primefaces -


i've set jdbc realm on gf 4.1 server , configured web.xml , glassfish-web.xml etc. idea when user trying access restricted resource, primefaces "login" dialog shown necessary input fields. after having logged in, user should redirected desired page.

whenever scenario happens parameter (?key=login) send page on basis supposed display login-dialog executing method in backing bean. when following line included in backing bean

requestcontext.getcurrentinstance().execute("pf('logindialog').show();"); 

the "logindialog" isn't rendered (included). have 2 questions: why isn't dialog rendered in index.xhtml? , bad approach together? here web.xml:

<login-config>     <auth-method>form</auth-method>     <realm-name>testrealm</realm-name>     <form-login-config>         <form-login-page>/index.xhtml?key=login</form-login-page>         <form-error-page>/loginerror.xhtml</form-error-page>     </form-login-config> </login-config> <security-constraint>     <display-name>admin pages</display-name>     <web-resource-collection>         <web-resource-name>protected admin area</web-resource-name>         <description/>         <url-pattern>/admin/*</url-pattern>         <http-method>get</http-method>         <http-method>post</http-method>         <http-method>head</http-method>         <http-method>put</http-method>         <http-method>options</http-method>         <http-method>trace</http-method>         <http-method>delete</http-method>     </web-resource-collection>     <auth-constraint>         <description/>         <role-name>admin</role-name>     </auth-constraint>     <user-data-constraint>         <description/>         <transport-guarantee>confidential</transport-guarantee>     </user-data-constraint> </security-constraint> 

index.xhtml:

<ui:composition template="/template.xhtml">     <f:metadata>         <f:viewparam name="key" value="#{logoutbean.key}"/>         <f:viewaction action="#{logoutbean.showlogindialog()}"/>     </f:metadata>      <ui:define name="title">         <h:outputtext value="#{bundle.listtestusertitle}"></h:outputtext>     </ui:define>     <ui:define name="body">         <h:form id="indexform">             <h:body>                 select want go:                 <br />                 <h:link outcome="admin/index" value="to admin section"/><br />                 <h:link outcome="user/index" value="to user section" />             </h:body>         </h:form>         <ui:include src="/login.xhtml"/>     </ui:define> </ui:composition> 

login.xhtml:

<ui:composition>         <p:dialog             id="logindlg"              widgetvar="logindialog"              modal="true" resizable="false"             appendto="@(body)"              header="login here">              <h:form id="loginform">                   <h:panelgrid columns="2">                       <h:outputlabel for="username" value="username:" />                       <h:inputtext id="username" value="#{logoutbean.username}" />                        <h:outputlabel for="password" value="password:" />                       <h:inputsecret id="password" value="#{logoutbean.password}" />                        <h:commandbutton id="loginbutton" value="login" action="#{logoutbean.login()}" />                   </h:panelgrid>             </h:form>         </p:dialog>     </ui:composition> 

logoutbean:

public class logoutbean implements serializable { private string key;  public string getkey() {     return key; }  public void setkey(string key) {     this.key = key; }  public void showlogindialog() {     if ("login".equalsignorecase(key)) {         requestcontext context = requestcontext.getcurrentinstance();         context.execute("pf('logindialog').show();");     } } 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -