views:

235

answers:

1

I'm trying to integrate Seam and Flex with GraniteDS, with the goal of implemenenting a code generation tool for main use cases of CRUD operations.

One of my needs is to have the possibility to generate a combo box to reference a parent entity from another. For example, a state combo box in my county edition/creation screen.

My first attempts have failed because of lazy loading problems.

Has anyone have code that already does this?

A: 

You can do this easily using data binding. Just bind the state-combobox's dataProvider to the selectedItem of the country-combobox.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:ComboBox id="countries" dataProvider="{xml.country}" labelField="name"/>
    <mx:ComboBox id="state" dataProvider="{countries.selectedItem.state}"/>
 <mx:Model id="xml">
  <root>
    <country>
      <name>USA</name>
      <state>AL</state>
      <state>TX</state>
      <state>NY</state>
    </country>
    <country>
      <name>India</name>
      <state>AP</state>
      <state>UP</state>
      <state>TN</state>
    </country>
  </root>
 </mx:Model>
</mx:Application>
Amarghosh
What I actually need is to have, defining an entity like state (with fields such as Name -Arizona, Florida, New York, etc.- and 2-letter code -AZ, FL, NY, etc.-), a combo box where users can define to which country the state belongs to. For example, I should have a form with Name: Arizona, 2-letter code: AZ and Country: USA.I have State.java, JPA-annotated like this:@Entity @EntityListeners(DataListener.class)public class State implements Serializable, IUID { ... @ManyToOne(fetch = FetchCountry.LAZY) @JoinColumn(name = "country_id") private Country country; ...}
Rodrigo
Edit the question and add this info there.
Amarghosh