voyent
Navigation problem  XML
Forum Index -> Components
Author Message
grahams

Joined: 26/May/2006 00:00:00
Messages: 27
Offline


I am trying to implement an initial check in my application to make sure various required resources are available and if not, put up an error page. I am trying to do this using a PhaseListener which then redirects to an error page if something is amiss.

However whever the PhaseListener tries to do the redirect I get a blank screen. Is there something I am missing?
Here are the code snippets:

public class CheckResourceListener implements PhaseListener {
public CheckResourceListener() {
}

public void afterPhase(PhaseEvent phaseEvent) {
System.out.println("entering phase listener");
FacesContext context = phaseEvent.getFacesContext();
if (thereIsAProblem()) {
NavigationHandler nh = context.getApplication().getNavigationHandler();
nh.handleNavigation(context,null,"error");
}
}

public void beforePhase(PhaseEvent phaseEvent) {
}

public PhaseId getPhaseId() {
return PhaseId.RESTORE_VIEW;
}

---

<navigation-rule>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/error.iface</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
<lifecycle>
<phase-listener>com.simmsconsulting.rulebuilder.CheckResourceListener</phase-listener>
</lifecycle>
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi,

Try this:

public void beforePhase(PhaseEvent phaseEvent) {
System.out.println("entering phase listener");
if (thereIsAProblem()) {
FacesContext context = phaseEvent.getFacesContext();
NavigationHandler nh = context.getApplication().getNavigationHandler();
nh.handleNavigation(context,context.getViewRoot().getViewId(),"error");
}
}

Thanks,
Philip

.
grahams

Joined: 26/May/2006 00:00:00
Messages: 27
Offline


I tried your solution but I am still getting the same problem with the blank screen.

The navigation rule works correctly if I have a commandbutton that returns "error" outcome, but not from the phaselistener.

Graham.
fabmars

Joined: 24/Aug/2006 00:00:00
Messages: 73
Offline


Well I did such thing by adding a filter on top of the Persistent Faces Servlet.

However this has some drawbacks : IceFaces passes a lot of things thru the Persistent Faces Servlet.

Thus, in the doFilter method, you have to chain.doFilter directly the servlet path "/blank.iface", and only process all the rest ending by ".iface".

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
HttpServletRequest hRequest = (HttpServletRequest)request;
String servlet = hRequest.getServletPath();

log.debug("doFilter: " + servlet);

if(servlet.endsWith(".iface") && !servlet.equals("/blank.iface"))
{
checkAndDoChainYourStuff(request, response, chain);
}
else
{
log.info("Doesn't need filtering: " + servlet);
chain.doFilter(request, response);
}
}

http://www.suntriprecords.com
grahams

Joined: 26/May/2006 00:00:00
Messages: 27
Offline


A filter might be a possible solution but I need to access backing beans to check if resources are available.

Can I do the following from within a filter?

BackingBean1 bb = (BackingBean1)context.getApplication().createValueBinding("#{bean1}").getValue(context);
grahams

Joined: 26/May/2006 00:00:00
Messages: 27
Offline


I have continued testing and it appears to be the case that the code works with a regular JSF application but when used in the ICEFaces context the redirection to a specific outcome produces a blank screen.

I have attached a WAR that demonstrates the problem.

Could you confirm if this is deemed a bug that will be fixed, or if it is a 'feature' I have to live with.

Thanks

Graham.
 Filename Test1.war [Disk] Download
 Description No description given
 Filesize 5866 Kbytes
 Downloaded:  108 time(s)

 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team