After playing with the value encoder, I found this method to be slightly
better since it will handle newly created session objects / existing objects
and other. 

    @SuppressWarnings("unchecked")
    public ValueEncoder getSelectEncoder() {
        return new ValueEncoder<Funding>() {
            public String toClient(Funding value) {
                if (value == NEW_FUNDING) {
                    return NEW_FUNDING_ID;
                } else {
                    Long key = value.getTempId();
                    return key.toString();
                }
            }

            public Funding toValue(String clientValue) {
                if (NEW_FUNDING_ID.equals(clientValue))  {
                    return NEW_FUNDING;
                } else {
                    for (Funding _funding :
getPurchaseRequest().getFundings()) {
                        if (_funding.getTempId() ==
Long.parseLong(clientValue)) {
                            return _funding;
                        }
                    }
                }
                return null;
            }
        };
    }

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/T5-Select-Menu-with-Other-Option-tp4520881p4539330.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to