やっぱり駄目か・・

ここのところ、駄目だろうとは思いつつも以下のコードとICEfacesとの両立はできないものか試していました。

<f:view beforePhase="#{hoge.hoge}">

で、ICEfacesのコードをこんな感じにしてみました。

package com.icesoft.faces.webapp.parser;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.digester.Rule;
import org.xml.sax.Attributes;

import java.lang.reflect.Method;

import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import javax.faces.webapp.UIComponentTag;
import javax.faces.webapp.UIComponentELTag;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import java.util.HashMap;
import javax.faces.event.PhaseEvent;


public class ELSetPropertiesRule extends Rule {

    public void begin(Attributes attributes) throws Exception {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        HashMap values = new HashMap();
        Object top = digester.peek();

        for (int i = 0; i < attributes.getLength(); i++) {
            String name = attributes.getLocalName(i);
            if ("".equals(name)) {
                name = attributes.getQName(i);
            }
            String value = attributes.getValue(i);

            //take a guess at the types of the JSF 1.2 tag members
            //we are probably better off doing this reflectively
            if (name != null) {
                values.put(name, value);
                if (("id".equals(name)) ||
                    ("name".equals(name)) ||
                    ("var".equals(name))) {
                    values.put(name, value);
                } else if (top instanceof UIComponentTag) {
                    //must be a JSF 1.1 tag
                    values.put(name, value);
                } else if ("action".equals(name)) {
                    values.put(name,
                               getMethodExpression( facesContext, name, value,
                                                    null ));
                } else if ("validator".equals(name)) {
                    values.put(name,
                            getMethodExpression( facesContext, name, value,
                                    null ));
                } else if ("actionListener".equals(name)) {
                    values.put(name,
                               getMethodExpression(facesContext, name, value,
                                                   ActionEvent.class));
                } else if ("valueChangeListener".equals(name)) {
                    values.put(name,
                               getMethodExpression(facesContext, name, value,
                                                   ValueChangeEvent.class));
                } else {
                    values.put(name,
                               getValueExpression(facesContext, name, value));
                }
                if (top instanceof javax.faces.webapp.UIComponentELTag) {
                    //special case for
                    //com.sun.faces.taglib.jsf_core.ParameterTag
                    //and potentially others
                    if ("name".equals(name))  {
                        values.put(name,
                                   getValueExpression(facesContext, name, value));
                    } else if ("locale".equals(name)) {
                        values.put(name,
                                   getValueExpression(facesContext, name, value));
                    } else if ("beforePhase".equals(name)) {
                        values.put(name,
                                    getMethodExpression(facesContext, name, value,
                                                   PhaseEvent.class));
                    } else if ("afterPhase".equals(name)) {
                        values.put(name,
                                    getMethodExpression(facesContext, name, value,
                                                   PhaseEvent.class));
                    }
                } else {
                    //reflection based code as mentioned above.  More likely
                    //to be correct, but performance may not be as good,
                    //so only applying it in a specific case
                    if ("name".equals(name))  {
                        Method setNameMethod = null;
                        try {
                            setNameMethod = top.getClass().getMethod("setName",
                                                                     new Class[] { ValueExpression.class } );
                        } catch (Exception e)  { }
                        if (null != setNameMethod)  {
                            values.put(name,
                                       getValueExpression(facesContext, name, value));
                        }
                    }

                }

            }
        }


        BeanUtils.populate(top, values);
    }

    private ValueExpression getValueExpression(FacesContext facesContext,
                                               String name, String value)  {

        Class argType = Object.class;
        // For some reason, tab index is typed to be a String, even though
        //  it can only be positive integral values
        if (!name.equals("tabindex")) {
            try {
                if (value.equalsIgnoreCase("true") ||
                    value.equalsIgnoreCase("false") ) {
                    argType = Boolean.class;
                } else if (null != Integer.valueOf(value)) {
                    //attempt to coerce to Integer type for standard JSF components
                    argType = Integer.class;
                }
            } catch (NumberFormatException e) {
            }
        }


        ValueExpression valueExpression =
                facesContext.getApplication().getExpressionFactory()
                        .createValueExpression(
                                facesContext.getELContext(),
                                value, argType );

        return valueExpression;
    }

    private MethodExpression getMethodExpression(FacesContext facesContext,
                                                 String name, String value,
                                                 Class argType)  {
        Class[] argTypes = new Class[]{};
        if (null != argType) {
            argTypes = new Class[]{argType};
        }

        MethodExpression methodExpression =
                facesContext.getApplication().getExpressionFactory()
                        .createMethodExpression(
                                                facesContext.getELContext(),
                                                value, String.class,
                                                argTypes);
        return methodExpression;
    }
}

beforePhaseとafterPhaseを追加しただけなのですが、この変更でExceptionは吐かなくなりました。
が、動かない・・・。無視されっぱなしですね。ここから先はどこを見ればいいのか見当もつきません。この件はここらであきらめるとします。

とりあえず今後はVisual Web ICEfacesでいじってみることにします。