Hello all,

I am new to Tapestry, and have been working through several of the tutorial
examples.  Something in particular that I am trying to do (and struggling to
do so) is the chaining together of multiple select components.  The approach
to do so appears fairly straightforward, as documented towards the bottom of
the page here:

http://tapestry.apache.org/tapestry5.2-dev/tapestry-core/ref/org/apache/tapestry5/corelib/components/Select.html
http://tapestry.apache.org/tapestry5.2-dev/tapestry-core/ref/org/apache/tapestry5/corelib/components/Select.html
 

So, what I want to do is:

1.  Load up a page that has a single populated select component visible
2.  When a value is selected, a second select component should become
visible, populated with values specific to what was chosen in the first
select component

The linked example above describes exactly this, and so I copied this code
into my project.  This included the following files:

*1.  CarMaker.java*

public enum CarMaker
{
    MERCEDES, AUDI, BMW;
}


*2.  SelectZoneDemo.tml*

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
   <t:form>
      <p>
         <t:errors />
      </p>
      <p>
         <t:select t:id="carMaker" validate="required"
                   zone="modelZone" />
      </p>
      
      <t:zone t:id="modelZone" id="modelZone">
         <t:if test="carMaker">
           <p>
              <t:select t:id="carModel" model="availableModels"
validate="required"/>
           </p>
         </t:if>
      </t:zone>
      
      <p>
         <t:submit value="literal:Submit" />
      </p>
   </t:form>

</html>

*3.  SelectZoneDemo.java*

public class SelectZoneDemo
{
   
   @Inject
   private Messages messages;
   
   @Property
   @Persist
   private CarMaker carMaker;
   
   @Property
   @Persist
   private String carModel;

   @InjectComponent
   private Zone modelZone;
   
   @Property
   @Persist
   private List<String> availableModels;
    
    public Object onValueChanged(CarMaker maker) 
    {
       availableModels = findAvailableModels(maker);
       
       return modelZone.getBody();
    }
    
    public List<String> findAvailableModels(final CarMaker maker) 
    {
      switch (maker) 
      {
         case AUDI:
            return Arrays.asList("A4", "A6", "A8");
         case BMW:
            return Arrays.asList("3 Series", "5 Series", "7 Series");
         case MERCEDES:
            return Arrays.asList("C-Class", "E-Class", "S-Class");
         default:
            return Arrays.asList();
       }
    }    
}

Now, this all compiles fine, and using Jetty I can quickly start up the
server and access the SelectZoneDemo page.  When the page loads, the
"CarMaker" select is visible and populated.  When I select a value from this
component, I have verified that the onValueChanged method in
SelectZoneDemo.java is called (this was verified by adding the @Log
annotation).  However, the method never exits and never returns the
modelZone.getBody() to the page.  What I see in the console is the
following:

[DEBUG] pages.SelectZoneDemo [ENTER] onValueChanged(BMW)
[DEBUG] pages.SelectZoneDemo [ENTER] findAvailableModels(BMW)
[DEBUG] pages.SelectZoneDemo [ EXIT] findAvailableModels [["3 Series", "5
Series", "7 Series"]]

As you can see, there's no EXIT log for onValueChanged.

What I've been able to determine through some trial and error, is that the
point at which the method "hangs" is on this line of onValueChanged:

availableModels = findAvailableModels(maker);

Furthermore, through additional testing I was able to determine that the act
of setting any value at all to availableModels will result in the
onValueChanged method not exiting.  For example, I tried simply doing this:

availableModels = new ArrayList<String>();

...and got the same result.

Now, if I comment out the line that sets a value to availableModels, the
onValueChanged method will exit, but the modelZone on SelectZoneDemo.tml
remains hidden.

At this point, I'm completed stumped.  I've googled everything that I can
think of, and at this point I'm sure that my problem must be a fundamental
misunderstanding of how Tapestry works.  If anyone could offer some
assistance, I would be very grateful.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Chaining-of-Select-components-tp4705879p4705879.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

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

Reply via email to