-
-
2. Re: Auto Submit
djkrite Dec 17, 2008 9:54 PM (in response to zjda)Whoops my markup didn't show, here:
<body onload="doSomeThing()">
-
3. Re: Auto Submit
zjda Dec 19, 2008 11:55 PM (in response to zjda)Thank you for your suggestion. Actually, I did use the onload as the following code. However, it did not work. IE keeps refreshing and FF does nothing. I set a break point in #{sessionInfo.loginAction}, but it never stops, meaning no request sends to the method. Any idea?
-ZJ<body style="margin: 0px;" onload="document.loginForm.submit();"> <f:view> <a4j:include id="header" viewId="/pages/header.xhtml" /> <h:form id="loginForm"> <h:panelGrid columns="3" cellspacing="5px" cellpadding="5px"> <h:outputLabel value="User Name:" for="username" /> <h:inputText id="username" value="#{sessionInfo.username}" /> <h:message for="username" errorClass="ValidateError" /> <h:outputLabel value="Password:" for="password" /> <h:inputSecret id="password" value="#{sessionInfo.password}" /> <h:message for="password" errorClass="ValidateError" /> <rich:spacer></rich:spacer> <h:commandButton value="Login" action="#{sessionInfo.loginAction}" /> <rich:spacer></rich:spacer> </h:panelGrid> </h:form> <a4j:include id="footer" viewId="/pages/footer.xhtml" /> </f:view>
-
4. Re: Auto Submit
djkrite Dec 22, 2008 1:04 PM (in response to zjda)you may have to specify: "type=submit" on the "h:commandButton". i would also check the source of the page after it renders. you could also tie a "a4j:jsFunction" to the "loginAction" and call then call the javascript method defined in the "a4j:jsFunction" component.
-
5. Re: Auto Submit
zjda Dec 24, 2008 2:01 PM (in response to zjda)Thanks. I added "type=submit", but it did not help. Here is the source of the page:
<body style="margin: 0px;" onload="javascript:document.loginForm.submit();"> ... <form id="loginForm" name="loginForm" method="post" action="/test/faces/pages/authentication.jsp" enctype="application/x-www-form-urlencoded"> ... <input type="submit" name="loginForm:j_id51" value="Login" />
I will try a4j:jsFunction as you suggested.
Again, thank you and happy holiday.
-ZJ -
6. Re: Auto Submit
zjda Dec 27, 2008 8:31 PM (in response to zjda)I looked at a4j:jsFunction and I think that it is not good for this case. Instead, I created a AuthenticationServlet which does the job.
Thank you and happy New Year.
-ZJif (request.getSession().getAttribute(UserSessionManager.USER_SESSION) == null) { String userName = request.getParameter("username"); String password = request.getParameter("password"); if( userName == null || userName.length() == 0 || password == null || password.length() == 0 ) { response.sendRedirect("faces/pages/authentication.jsp"); return; } else { try { ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); IApi api = (IApi) context.getBean("api"); api.authenticate(userName, password, request); } catch (ApiException ae) { ae.printStackTrace(); } } } response.sendRedirect("faces/pages/main.jsp");