Robert, The Option component expects that the selected parameter is bound to an expression that it can read *and* write to. In other words it expects the expression to evaluate to a bean property.
You expression works on a render (read) as it evals to a boolean and that's ok, a value would be what a getter method would return. However, on a rewind (write), Option is trying to set the property that the expression evaluates to - and that doesn't work with the expresson you have. Hence the exception. Geoff public class InappropriateExpressionException extends OgnlException Exception thrown if an OGNL expression is evaluated in the wrong context; the usual case is when an expression that does not end in a property reference is passed to setValue. http://www.opensymphony.com/ognl/api/ognl/InappropriateExpressionException.html On 5/10/06, Robert Hannebauer <[EMAIL PROTECTED]> wrote:
Hi, i tried to implement two dependent select boxes. This is my very simple test case. Home.html: <html jwcid="@Shell" title="Test"> <body jwcid="@Body"> <span jwcid="@Form"> <select jwcid="@Select" multiple="ognl:false"> <span jwcid="@Foreach" source="ognl:dayValues" value="ognl:day" index="ognl:dayIndex"> <option jwcid="@Option" selected="ognl:date.get(@[EMAIL PROTECTED]) == day" label="ognl:day" /> </span> </select> <select jwcid="@Select" multiple="ognl:false" onchange="javascript:this.form.events.refresh();" > <span jwcid="@Foreach" source="ognl:monthValues" value="ognl:month" index="ognl:monthIndex"> <option jwcid="@Option" selected="ognl:date.get(@[EMAIL PROTECTED]) eq monthIndex" label="ognl:month"/> </span> </select> </span> </body> </html> Home.java: package test.page; import java.text.DateFormatSymbols; import java.util.Calendar; import java.util.Date; import java.util.Iterator; import org.apache.commons.collections.iterators.ArrayIterator; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.engine.IPageLoader; import org.apache.tapestry.html.BasePage; import org.apache.tapestry.spec.IComponentSpecification; public abstract class Test extends BasePage { public final static int DAYS[] = new int[31]; static { for (int i = 1; i <= 31; ++i) { DAYS[i-1] = i; } } public abstract String getMonth(); public abstract void setMonth(String s); public abstract int getMonthIndex(); public abstract void setMonthIndex(int l); public abstract int getDay(); public abstract void setDay(int i); public abstract int getDayIndex(); public abstract void setDayIndex(int l); public abstract Calendar getDate(); public abstract void setDate(Calendar date); public Iterator getMonthValues() { String months[] = new DateFormatSymbols(getPage().getLocale()).getMonths(); if (months[months.length - 1].length() > 1) { return new ArrayIterator(months); } return new ArrayIterator(months, 0, months.length-1); } public Iterator getDayValues() { return new ArrayIterator(DAYS, 0, getDate().getActualMaximum(Calendar.DAY_OF_MONTH)); } @Override public void finishLoad(IRequestCycle arg0, IPageLoader arg1, IComponentSpecification arg2) { super.finishLoad(arg0, arg1, arg2); Calendar c = Calendar.getInstance(getPage().getLocale()); c.setTime(new Date()); setDate(c); } } The first time the page renders without errors. The correct values are preselected. But when i select a new month i get an exception: org.apache.hivemind.ApplicationRuntimeException Unable to update OGNL expression '<parsed OGNL expression>' of [EMAIL PROTECTED] to false: Inappropriate OGNL expression: date.get(@[EMAIL PROTECTED]) == day ognl.InappropriateExpressionException Inappropriate OGNL expression: date.get(@[EMAIL PROTECTED]) == day What's going wrong? I'm running out of ideas. Robert --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- The Spindle guy. http://spindle.sf.net Blog: http://jroller.com/page/glongman Other interests: http://www.squidoo.com/spaceelevator/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]