Xoetrope

 Wiki : POJO

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

POJO Support


POJOs or Plain Old Java Objects support has been added in XUI 3.0. The new support for using POJOs as a backing for the XUI data model means that POJOs can be bound to user interface components just as easily as static data or database data. The POJO model may be home grown or generated with tools such as JDO or Hibernate. Most of the configuration takes place automatically via reflection and little needs to be done other than pointing XUI at the root of the POJO model.

Here's a sample configuration, showing how some POJO properties are overridden and some finders are refined.

  1. <Pojos id="beaumont">
  2.   <context class="net.xoetrope.clinic.ClinicInstance" config="pojoConfig.xml"/>
  3.   <overrides>
  4.     <pojo id="patient" class="net.xoetrope.clinic.Patient">
  5.       <!--identifier id="id" method="getPatientId"/-->
  6.       <collection id="patientId" method="getPatients"/>
  7.     </pojo>
  8.     <pojo id="clinic" class="inet.xoetrope.clinic.ClinicDAO">
  9.       <property id="id" getter="getClinicId"/>
  10.       <finder id="patients" getter="getPatients" class="net.xoetrope.clinic.Patient">
  11.         <key id="name" method="getName()"/>
  12.       </finder>
  13.       <property id="name" getter="getClinicName" setter="setClinicName"/>
  14.     </pojo>
  15.   </overrides>
  16.   <root id="pojo" class="net.xoetrope.clinic.ClinicDAO">
  17.     <param class="String" value="Clinic"/>
  18.   </root>
  19. </Pojos>


The POJOs are then attched via the root object that serves to connect the XUI model and POJO hierarchy. A sample usage is as follows:

  1. <XPage class="net.xoetrope.swing.XDialog" title="Test POJOs" padding="0">
  2.     <Components>
  3.         <Label name="clinicName" x="10" y="10" w="200" h="20" style="stripe"/>
  4.     </Components>
  5.     <Data>
  6.         <Bind target="clinicName" source="pojo/patients@idx=[1]/name"/>
  7.     </Data>
  8. </XPage>


where pojo/patients@idx=[1]/name refers to the second item returned by the getPatients() method of the root object. The root object as specified in the configuration is an instance of the ClinicDAO class. The root instance can be parametrized or alternatively it can be instantiated by the POJO context class.

There are no comments on this page. [Add comment]

Page was generated in 0.5408 seconds