-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I create a crud zk project by following a tutorial ij this site, which uses spring security.It works when i use a simple login form, but not, with spring security, is there any way to pass parameter to zul page using spring security,
Hello lovasoa,
Have you checked out the official documentation?
https://www.zkoss.org/wiki/ZKDeveloper'sReference/Integration/Security/Spring_Security
Best Regards,
Darksu
Thank you for your response Darksu, but I still can't resolve my problem What I want to do is to get data from login form and show it in an other zul page I tried this example by using HashMap<string, object="">, This is the login.zul,
... <groupbox> <h:form id="f" name="f" action="j_spring_security_check" method="POST" xmlns:h="<a href=" http:="" www.w3.org="" 1999="" xhtml"="">http://www.w3.org/1999/xhtml"> <grid >="" <columns="" sizable="false"> <column width="50%"/> <column width="50%"/> </columns> <rows> <row> <label value="LOGIN"/> <textbox id="u" name="j_username"/> </row> <row> <label value="MOT DE PASSE"/> <textbox id="p" type="password" name="j_password"/> </row> <row >="" <h:input="" sclass="btn-primary" type="submit" value="SE CONNECTER" onclick="@command('set')"/> <h:input sclass="btn-primary" type="reset" value="RESET"/>
</row>
</rows>
</grid>
</h:form>
</groupbox>
...
And this is the MyUserDetailsService class, the example I follow uses MySQL asdatabase(it works well), I added PassParameter class in this class, as shown:
--//-- ... public class MyUserDetailsService implements UserDetailsService { ... //public UserDetails loadUserByUsername(String username) // throws UsernameNotFoundException, DataAccessException { ... @SuppressWarnings("serial") public class Passparameter extends SelectorComposer<window>{ @Wire Textbox u; @Wire Textbox p; @Listen("onClick=#showWindow") public void submit() { final HashMap<string, object=""> map = new HashMap<string, object="">(); map.put("u", u.getValue()); } }
--//--
And in Informations.zul page,
<window title="new page title" border="normal" apply="crudexample.controller.Informations"> <label value="You have entered as username: "></label> <separator></separator> <textbox id="u" value="@{$composer.u}"></textbox> <separator></separator> </window> </zk>
The Informations class is:
... package domain;
import org.zkoss.zk.ui.Execution; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Wire; import org.zkoss.zul.Textbox; import org.zkoss.zul.Window;
@SuppressWarnings("serial") public class Informations extends SelectorComposer<window> { @Wire Textbox u; public void doAfterCompose(Window comp) throws Exception { super.doAfterCompose(comp); final Execution execution = Executions.getCurrent(); u.setValue((String) execution.getArg().get("u")); comp.setAttribute("cp", this); }
} --//--
Could you tell me where is the problem, because I don't know what doesn't work in the code,
Hello lovasoa,
Please refer to the following documentation in order to save the user credentials:
https://www.zkoss.org/wiki/ZKEssentials/Chapter8:_Authentication
Only concern if you actually want to save the information in the session.
Best Regards,
Darksu
Asked: 2017-01-16 13:03:54 +0800
Seen: 62 times
Last updated: Jan 17 '17