JSF a4j:commandLink isn't working after redirect
androsov Apr 26, 2013 4:26 PMNow I write my View presentor using JSF and have some troubles.
I have 2 commandLinks which must change view (it will be realized later). They call redirect-method. Adress bar is chaged from "http://localhost:8080/frontoffice-jsf/main.jsf" "to http://localhost:8080/frontoffice-jsf/main.jsf#1".
After that all two links are inactive (they actions are not called). What can I do? I need to use them more than 1 time.
<!--navigateView--> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"> <h:form> <a4j:commandLink value="view1" action="#{navigateBean.goToPlace}" render="out" execute="@form"> <f:param name="newPlace" value="np1" /> </a4j:commandLink> </h:form> <h:form> <a4j:commandLink value="view2" action="#{navigateBean.goToPlace}" render="out" execute="@form"> <f:param name="newPlace" value="np2" /> </a4j:commandLink> </h:form> </ui:composition>
//Bean package ru.deltasolutions.jsf.navigate; import java.io.IOException; import java.io.Serializable; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; @ManagedBean @ViewScoped public class NavigateBean implements Serializable { private static String path = "main.jsf"; public void goToPlace() throws IOException { ExternalContext ec = FacesContext.getCurrentInstance() .getExternalContext(); ec.getApplicationMap().get("newPlace"); String add = (String) ec.getApplicationMap().get("newPlace"); ec.redirect(path+"#"+add); int i = 7; }
Please don't watch on String add - it isn't right. Just I tryed to debug it. Problem only in redirection