You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nazarhussain_s <na...@gmail.com> on 2011/05/04 11:56:57 UTC

Help required regarding IPropertySelectionModel in Tapestry 4

Hi,
     I am having a Home.html in which i have two drop downs -  Country and
City . On selection of countryfrom the first drop down the corresponding
cities need to be populated in the second drop down.While running the
application I am getting the following error.





[ +/- ] Exception: Unable to read OGNL expression '<parsed OGNL expression>'
of $DropDown_0@3c1[Home]: cityModel
 org.apache.tapestry.BindingException
binding: ExpressionBinding[Home cityModel]
location: context:/WEB-INF/Home.page, line 17, column 51
12          <binding name="listener" value="listener:onCountryChange" />
13      </component>
14
15      <component id="city" type="PropertySelection">
16          <binding name="value" value="city"/>
17          <binding name="model" value="cityModel" />
18          <binding name="listener" value="listener:onLoad" />
19   </component>
20
21 </page-specification>

PFB the Home.html ,Home.page and DropDown.java. Can u please provide some
clue as to how to resolve this issue?

Home.html
------------
<html jwcid="@Shell" title="Drop Down">
<body jwcid="@Body">

               <form jwcid="form">
                       <select jwcid="country"></select>
                       <br/>
                       
                   <select jwcid="city"></select>
                   
               </form>

</body>
</html>

Home.page
-----------
<?xml version="1.0"?>
&lt;!DOCTYPE page-specification PUBLIC
 &quot;-//Apache Software Foundation//Tapestry Specification 4.0//EN&quot;
 &quot;http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd&quot;&gt;
<page-specification class="com.tapestry.DropDown">
   <component id="form" type="Form">
   </component>

   <component id="country" type="PropertySelection">
       <binding name="value" value="country" />
       <binding name="model" value="countryModel"/>
       <binding name="listener" value="listener:onCountryChange" />
   </component>

   <component id="city" type="PropertySelection">
       <binding name="value" value="city"/>
       <binding name="model" value="ognl:cityModel" />
       <binding name="listener" value="listener:onLoad" />
       </component>

</page-specification>

DropDown.java
----------------
package com.tapestry;

           import org.apache.tapestry.IRequestCycle;
           import org.apache.tapestry.annotations.EventListener;
           import org.apache.tapestry.form.IPropertySelectionModel;
           import org.apache.tapestry.html.BasePage;

           public abstract class DropDown extends BasePage{


               public abstract String getCountry();

               public abstract void setCountry(String country);

               @EventListener(targets = { "country" }, events = { "onchange"
})
               public void onCountryChange(IRequestCycle cycle) {

                       setCountry(getCountry());
               }


               public IPropertySelectionModel getCountryModel(){

                       return new StringPropertySelectionModel(new String[]
{ "US","UK","China","Chile"});
               }



            public IPropertySelectionModel getCityModel(){


                   if (getCountry().equals("US")) {
                       System.out.println("in us");
                               return new StringPropertySelectionModel(new
String[] { "New York",
                                               "Boston", "Chicago" });
                       }
                   else if(getCountry().equals("China")){
                       System.out.println("in china");
                               return new StringPropertySelectionModel(new
String[] { "Beijing",
                                               "Shanghai" });
                       }
                   else if(getCountry().equals("UK")){
                       System.out.println("in uk");
                               return new StringPropertySelectionModel(new
String[] { "London" ,
                                               "Birmingham" });
                   }
                   else
                   {
                      System.out.println("in chile");
                          return new StringPropertySelectionModel(new
String[] { "Santiago",
                               "Arica" });
                   }
             }


           }

The value of getCountry() in the method getCityModel() is coming as null.
Can you please suggest how it can be retrieved in this function?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Help-required-regarding-IPropertySelectionModel-in-Tapestry-4-tp4369410p4369410.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Help required regarding IPropertySelectionModel in Tapestry 4

Posted by LLTYK <LL...@mailinator.com>.
Either give it an initial value in pageBeginRender and don't allow a blank
selection, or allow it to be null and do null-safe equals checks in
getCityModel (returning an empty city list on null or something).

--
View this message in context: http://tapestry-users.832.n2.nabble.com/Help-required-regarding-IPropertySelectionModel-in-Tapestry-4-tp6330269p6330408.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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