Hello
I'm trying to implement a template with ui: include
but when I include on my login page the CommandButton does not invoke the listener
the index.xhtml
<p:layout fullPage="true">
<p:layoutUnit position="top" height="100">
<ui:include src="#{PageDispatcher.headerPage}" />
<!-- <ui:include src="#{PageDispatcher.contentPage}"/>
<ui:include src="#{PageDispatcher.footerPage}"/>-->
</p:layoutUnit>
<p:layoutUnit position="center" height="300" id="center">
<ui:include src="#{PageDispatcher.contentPage}"/>
</p:layoutUnit>
<p:layoutUnit position="bottom" height="200">
<ui:include src="#{PageDispatcher.footerPage}" />
</p:layoutUnit>
</p:layout>
the contentPage = loginPage ...dynamically chosen
login.xhtml
<h:form id="login">
<p:messages id="msgs" showDetail="true"/>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Username: *" />
<p:inputText value="#{loginBean.username}" id="username" required="true" label="username" />
<h:outputLabel for="password" value="Password: * " />
<h:inputSecret value="#{loginBean.password}" id="password" required="true" label="password" />
<f:facet name="footer">
<p:commandButton value="Login" update="msgs" actionListener="#{loginBean.login}" />
</f:facet>
</h:panelGrid>
</h:form>
the MenagedBean LoginBean
@ManagedBean
public class LoginBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private User user = null;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void login(ActionEvent actionEvent) {
System.out.println("login");
RequestContext context = RequestContext.getCurrentInstance();
FacesMessage msg = null;
boolean loggedIn = false;
LoginDao lDao = new LoginDao(SqlMapFactory.openSession());
user = lDao.getUser(this);
if(user != null ) {
loggedIn = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", username);
context.addCallbackParam("user", user);
} else {
loggedIn = false;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Invalid credentials");
}
if (context!=null)
context.addCallbackParam("loggedIn", loggedIn);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
if I look at the source of the page when I invoke the login page directly I agree that the action of the login form is actually the page itself, but if I look at the source of the page when the login page is dynamically included in the action of the form login is the index page.
I read most of the posts in the forum but have not found a solution,
Can you help me please
Thanks in advance
commandButton in dynamically loaded page
-
- Information
-
Who is online
Users browsing this forum: No registered users and 36 guests