Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tutorial:change_table [2020/04/21 11:38] (current)
Line 1: Line 1:
 +Adichatz generates one XML file by entity to display query result in a table control.\\
 +For example, the generated file for a <wrap adicode>​Customer</​wrap>​ class is described by an XML file called <wrap adicode>​$projectDirectory/​resources/​xml/​model/​customer/​CustomerTIGENERATED.axml</​wrap>:​
 +\\
 +<sxh xml; first-line: 1; title: excerpt from '​CustomerQUERYGENERATED.axml'​ file.>
 +<?xml version="​1.0"​ encoding="​UTF-8"​ standalone="​yes"?>​
 +<​includeTree xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​ xsi:​noNamespaceSchemaLocation="​http://​www.adichatz.org/​xsd/​v0.9.1/​generator/​includeTree.xsd">​
 +    <table sortedColumn="​customerIdTC"​ entityURI="​adi://​myproject/​model.customer/​CustomerMM"​ id="​table">​
 +        <include adiResourceURI="#​PARAM(CONTEXT_MENU)"​ id="​tableContextMenu"/>​
 +        <​crossReferences>​
 +            <​crossReference entitySetId="​rentals"​ description="#​MSG(customer,​ rentals)"​ axmlDetailURI="​adi://​myproject/​model.rental/​RentalDI"​ axmlTableURI="​adi://​myproject/​model.rental/​RentalTI"​ axmlQueryURI="​adi://​myproject/​model.rental/​RentalQUERY"/>​
 +            <​crossReference entitySetId="​payments"​ description="#​MSG(customer,​ payments)"​ axmlDetailURI="​adi://​myproject/​model.payment/​PaymentDI"​ axmlTableURI="​adi://​myproject/​model.payment/​PaymentTI"​ axmlQueryURI="​adi://​myproject/​model.payment/​PaymentQUERY"/>​
 +        </​crossReferences>​
 +        <​tableColumn property="​customerId"​ pattern="######"​ sorted="​true"​ id="​customerIdTC"/>​
 +        <​tableColumn property="​address"​ sorted="​true"​ id="​addressTC">​
 +            <​columnText>​return null != #​ROW().address ? #​ROW().address.address : &​quot;&​quot;;</​columnText>​
 +        </​tableColumn>​
 +        <​tableColumn property="​store"​ sorted="​true"​ id="​storeTC">​
 +            <​columnText>​return null != #​ROW().store ? String.valueOf(#​ROW().store.getStoreId()) : &​quot;&​quot;;</​columnText>​
 +        </​tableColumn>​
 +        <​tableColumn property="​firstName"​ sorted="​true"​ id="​firstNameTC"/>​
 +        <​tableColumn property="​lastName"​ sorted="​true"​ id="​lastNameTC"/>​
 +        <​tableColumn property="​email"​ sorted="​true"​ id="​emailTC"/>​
 +        <​tableColumn property="​active"​ pattern="​CHECK_ONLY"​ sorted="​true"​ id="​activeTC"/>​
 +        <​tableColumn property="​createDate"​ sorted="​true"​ id="​createDateTC"/>​
 +        <​tableColumn property="​lastUpdate"​ sorted="​true"​ id="​lastUpdateTC"/>​
 +    </​table>​
 +</​includeTree>​
 +</​sxh>​
 +<WRAP indic><​wrap adititle>​Remarks</​wrap>:​\\
 +  * Line 3 - Controller wraps a <wrap adicode>​table</​wrap>​ control and hosts rows of type <wrap adicode>​Customer</​wrap>​.
 +  * Line 4 - Context menu is passed as a parameter.
 +  * Lines 5-8 - Links give acces to Cross references (e.g all rentals of a customer).
 +  * Lines 11 and 14 - Displayed values for this column are computed.
 +</​WRAP>​
 +\\ \\
 +After [[tutorial:​complete_query|having completed query for Customer]] by adding jointures, displayed data can be enriched as shown below. ​
 +For example, create file <wrap adicode>​$projectDirectory/​resources/​xml/​model/​cutomer/​CustomerTI.xml</​wrap>​.
 +<sxh xml; highlight: [11,​14,​18,​21];​ title: excerpt from '​CustomerTI.axml'​ file.>
 +<?xml version="​1.0"​ encoding="​UTF-8"​ standalone="​yes"?>​
 +<​includeTree xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​ xsi:​noNamespaceSchemaLocation="​http://​www.adichatz.org/​xsd/​v0.9.1/​generator/​includeTree.xsd">​
 +    <​table sortedColumn="​customerIdTC"​ entityURI="​adi://​myproject/​model.customer/​CustomerMM"​ id="​table">​
 +        <​include adiResourceURI="#​PARAM(CONTEXT_MENU)"​ id="​tableContextMenu"/>​
 +        <​crossReferences>​
 +            <​crossReference entitySetId="​rentals"​ description="#​MSG(customer,​ rentals)"​ axmlDetailURI="​adi://​myproject/​model.rental/​RentalDI"​ axmlTableURI="​adi://​myproject/​model.rental/​RentalTI"​ axmlQueryURI="​adi://​myproject/​model.rental/​RentalQUERY"/>​
 +            <​crossReference entitySetId="​payments"​ description="#​MSG(customer,​ payments)"​ axmlDetailURI="​adi://​myproject/​model.payment/​PaymentDI"​ axmlTableURI="​adi://​myproject/​model.payment/​PaymentTI"​ axmlQueryURI="​adi://​myproject/​model.payment/​PaymentQUERY"/>​
 +        </​crossReferences>​
 +        <​tableColumn property="​customerId"​ pattern="######"​ sorted="​true"​ id="​customerIdTC"/>​
 +        <​tableColumn property="​firstName"​ sorted="​true"​ id="​firstNameTC">​
 + <​columnBackground>​return !row.isActive() ? #​COLOR(SWT.COLOR_YELLOW) : null;</​columnBackground>​
 + </​tableColumn>​
 +        <​tableColumn property="​lastName"​ sorted="​true"​ id="​lastNameTC">​
 + <​columnBackground>​return !row.isActive() ? #​COLOR(SWT.COLOR_YELLOW) : null;</​columnBackground>​
 + </​tableColumn>​
 +        <​tableColumn property="​active"​ pattern="​CHECK_ONLY"​ sorted="​true"​ id="​activeTC"/>​
 +        <​tableColumn property="​address"​ sorted="​true"​ id="​addressTC">​
 +            <​columnText>​return null != #​ROW().address ? #​ROW().address.address + &quot; - &quot; + #​ROW().address.city.city&#​xD;​ + &quot; - &quot; + #​ROW().address.city.country.country : &​quot;&​quot;;</​columnText>​
 +        </​tableColumn>​
 +        <​tableColumn property="​store"​ sorted="​true"​ id="​storeTC">​
 +            <​columnText>​return null != #​ROW().store ? #​MSG(customer,​ store) + &​quot;:&​quot;​ + #​ROW().store.address.city.city + &quot; - &quot; + #​ROW().store.address.city.country.country + &quot; (&quot; + #​ROW().store.staff.lastName + &​quot;​)&​quot;​ : &​quot;&​quot;;</​columnText>​
 +        </​tableColumn>​
 +        <​tableColumn property="​email"​ sorted="​true"​ id="​emailTC"/>​
 +        <​tableColumn property="​createDate"​ sorted="​true"​ id="​createDateTC"/>​
 +        <​tableColumn property="​lastUpdate"​ sorted="​true"​ id="​lastUpdateTC"/>​
 +    </​table>​
 +</​includeTree>​
 +</​sxh>​\\
 +**renders the following layout:**\\
 +{{tutorial:​table_controller.png?​600 | Table controller}}
 +<​html><​br clear="​all"></​html>​
 +<WRAP indic><​wrap adititle>​Explanations</​wrap>:​\\
 +File <wrap adicode>​CustomerTIGENERATED.axml</​wrap>​ is copied as file <wrap adicode>​CustomerTI.axml</​wrap>,​ so that, if a generation process occurs, changes will not be affected. ​
 +  * Lines 11 and 14: Background is <hi #​FFFF00>​**Yellow**</​hi>​ when <wrap adicode>​customer</​wrap>​ is not valid.  ​
 +  * Lines 18 and 21: Return computed value for <wrap adicode>​store</​wrap>​ and <wrap adicode>​address</​wrap>​.  ​
 +<​code><​columnText>​return null != #​ROW().address ? #​ROW().address.address
 +                + &quot; - &​quot; ​ + #​ROW().address.city.city
 +                + &quot; - &​quot; ​ + #​ROW().address.city.country.country : &​quot;&​quot;;</​columnText>​
 +</​code> ​               ​
 +is equivalent to
 +<​code><​columnText>​
 +if (null != customer.getAddress())
 + return customer.getAddress().getAddress() + " - "  ​
 +      + customer.getAddress().getCity().getCity() + " - "
 +      + customer.getAddress().getCity().getCountry().getCountry();​
 +else
 +    return "";​
 +</​columnText>​
 +</​code>​
 +So, this <wrap adicode>​table controller</​wrap>​ works with query containing all needed jointures. E.g. use example query described in page [[complete_query#​changed_query|complete query]].  ​
 +</​WRAP>​