-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jonathan Harley wrote:
> Cosma Colanicchia wrote:
>> Reading that wiki post:
>>
>>    "For these reasons [...] one should consider using a custom
>> Navigation Handler adding the following capabilities:"
>>
>> I've understood that you have to code and plug your custom navigation
>> handler to inplement this sort of navigation logic. I've never seen
>> using EL expressions in <to-view-id> elements, anyone know if this is
>> supported by the standard JSF nav. handler?
> 
> No, it isn't, but it's very easy to do. See for example
> http://forum.java.sun.com/thread.jspa?threadID=492721&messageID=2318174
> 
> 
> Jon.
Thanks for that Jon


Based on the info in that thread and the linked articles I've knocked up
my own Navigation handler.
The trouble is, I dont seem to be able to get the <to-view-id> part of
the navigation rule in order to fix the parameters.


Here is my Navigation handler.
package com.starjar.facestest;

import javax.faces.application.NavigationHandler;
import javax.faces.context.FacesContext;

/**
 * Based on
 * http://forum.java.sun.com/thread.jspa?threadID=492721&messageID=2318174
 *
 *
 * @author peter
 */
public class ParameterNavigationHandler extends NavigationHandler {

    NavigationHandler _base;

    /** Creates a new instance of ParameterNavigationHandler */
    public ParameterNavigationHandler(NavigationHandler base) {
        super();
        System.out.println("===IN ParameterNavigationHandler ctor =");
        this._base = base;
    }

    public void handleNavigation(FacesContext fc, String actionMethod,
String actionName) {
        System.out.println("====IN ParameterNavigationHandler =");

        _base.handleNavigation(fc, actionMethod, actionName);

        String viewId = fc.getViewRoot().getViewId();
        System.out.println("ORIGINAL VIEW " + viewId +
                " actionMethod " + actionMethod +
                " actionName " + actionName );
        if ((viewId.indexOf("#{") != -1) &&
                (viewId.indexOf("#{") < viewId.indexOf('}')))
        {
            String bviewId =
(String)fc.getApplication().createValueBinding(viewId).getValue(fc);
            System.out.println("NEW VIEW id " + bviewId );
            if (bviewId != null) {
                fc.getViewRoot().setViewId(bviewId);
            } else {
                // you can throw the exception here
            }
        }
    }
}


Values of fields
viewId = /secure/company/list.jsp
actionMethod = #{quickNewCompanyBean.create}
actionName = view-company

I was expecting one of these value to be the <to-view-id>
/secure/company/view.jsp?companyID=#{quickNewCompanyBean.companyID}


Im no JSF expert and feel completly out of my depth here.


Cheers
Peter Henderson


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEhc8HaeMEhGmZg50RAuBVAJ90lVNe5QjNRjOiHw3cAs6a1o2SnACeKgtx
u8IAWTxZ4JVD/2HjvvtRdtA=
=gxLN
-----END PGP SIGNATURE-----

Reply via email to