Hi List,

in many of my pages I find myself doing similar things. I collect data with a 
form and store it in a SessionState field. Then i forward to a summary page. In 
onActivate of summary page check for existence of SessionState value whith 
boolean valueExists. If value exists I show the summary and let user confirm.

To save me some code I thought of using Generic base page for that. The code 
follows:
public abstract class GenericEntityPage<T> {

    @SessionState
    private T value;

    private boolean valueExists;

    public T getValue() {
        return this.value;
    }

    public void setValue(final T value ) {
        this.value = value;
    }

    @OnEvent(value = EventConstants.ACTIVATE)
    Object checkValueExists() {
        if (!this.valueExists) {
            return this.getForwardPage();
        }
        else {
            return null;
        }
    }

    /**
     * @return the page to be forwarded to in case value does not exist.
     */
    protected abstract Object getForwardPage();
}

Doing so I get an error "Could not find a coercion from type java.lang.Object 
to type xyz" on the subclass page. I have looked for inspiration on ars-machina 
(http://www.arsmachina.com.br/project/tapestrycrud/usage). But there the 
generic values aren't used as SessionState but get/set in the code. Is it 
somehow possible to use generic fields as SessionState values?

Kind regards, nillehammer

==
http://www.winfonet.eu

Reply via email to