1 / 11

Symbolic Variables

Symbolic Variables. Laurent Guérin / v 0.9.9 / 2008 - April. What are symbolic variables ?. The symbolic variables are a set of predefined expressions for accessing server information in a Telosys tag attribute The variables are replaced by their value when the JSP is called Syntax :

Télécharger la présentation

Symbolic Variables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Symbolic Variables Laurent Guérin / v 0.9.9 / 2008 - April

  2. What are symbolic variables ? • The symbolic variables are a set of predefined expressions for accessing server information in a Telosys tag attribute • The variables are replaced by their value when the JSP is called • Syntax : • @{ variable_name, default_value, format } • Examples : <t:out v="code : @{agency1.code} - city : @{agency1.city}" /> <t:listrow onclick="alert('count=@{#count,,000} city=@{.city,???}')" > Telosys framework - Symbolic variables ( Laurent Guérin )

  3. What are symbolic variables ? • The symbolic variables are completely independent of the standard JSP Expression Language ( "EL" ). They can be used even in old Java servers that doesn't support EL and JSTL. • Where can they be used ? • In the "v" attribute of "t:out" • In every event attributes : onclick, onblur, … • In the specific following attributes :value txt title zone cl style disabled readonly Telosys framework - Symbolic variables ( Laurent Guérin )

  4. Symbolic variables : predefined values • Predefined names ( starting with "#" ) : • @{#count} the current count value in iterations from 1 to n • @{#index} the current index value in iterations from index-base (0 by default) to n • @{#session-id} the current session id • @{#user-login} the current user login • @{#user-language} the current user language • @{#user-role} the current user role Telosys framework - Symbolic variables ( Laurent Guérin )

  5. Symbolic variables for Java beans • Any Java bean can be accessed with the standard "dot" notation : • @{agency.city} value of the attribute "city" of the bean "agency" • @{.city} value of the attribute "city" of the "current bean" ( the "." in first position defines an attribute ) • @{agency} string value of the bean "agency" ( using the "toString" method of the bean ) • Example : <t:out v="The agency city is @{agency.city,NO CITY}"/> Telosys framework - Symbolic variables ( Laurent Guérin )

  6. Symbolic variables for Java beans • Bean search order : • When a bean is specified by a name ( e.g. @{agency.code} ), the name is searched in the following scopes order : • 1 – screen-context data ( Telosys ) (*) • 2 – screen-context attribute ( Telosys ) (*) • 3 – standard servlet request ( standard "request scope" ) • 4 – screen-session ( Telosys ) • 5 – standard http session (standard "session scope" ) • 6 – screen-application ( Telosys ) • 7 – standard servlet context (standard "application scope" ) (*) The screen-context is defined only in screen actions, not in a service call Telosys framework - Symbolic variables ( Laurent Guérin )

  7. Symbolic variables for DataSet • DataSet cells can be accessed with a number corresponding to the column number of the current DataRow ( 1 to n ) : • @{.1} or @{1} value of the column 1 • @{.2} or @{2} value of the column 2 • etc … • Example ( list with a Dataset ) : <t:listbody data="MYDATASET" height="240" indexbase="100" > <t:listrow > <t:listcell > <t:out v="@{#count}"/> </t:listcell> <t:listcell > <t:out v="@{#index,??,'0000'}"/> </t:listcell> <t:listcell > <t:out v="@{1,???}"/> </t:listcell> <t:listcell > <t:out v="@{2,??,'000'}"/> </t:listcell> <t:listcell > <t:out v="@{.3,??,'0000.00'}"/> </t:listcell> <t:listcell > <t:out v="@{.4,??,'Yes|No'}"/> </t:listcell> </t:listrow > </t:listbody > Telosys framework - Symbolic variables ( Laurent Guérin )

  8. Use cases • Print a bean attributes : • Using "with/without" tag : <table> <tr><td>Code</td><td><t:out v="code @{agency1.code,,'c000'}" /></td></tr> <tr><td>Name</td><td><t:out v="name @{agency1.name}" /> </td></tr> <tr><td>City</td><td><t:out v="city @{agency1.city,NO CITY}"/> </td></tr> </table> <t:with bean="agency1" scope="request" > <table border="1"> <tr> <td> <t:out v="Code = @{.code}" /> </td> </tr> <tr> <td> <t:out v="Name = @{.name}" /> </td> </tr> <tr> <td> <t:out v="City = @{.city}" /> </td> </tr> </table> </t:with> <t:without bean="agency1" scope="request" > <h2>Bean not found</h2> </t:without> Telosys framework - Symbolic variables ( Laurent Guérin )

  9. Use cases • Iterate on a list : <table> <t:iterate list="mylist" scope="session" indexbase="100" > <tr> <td> <t:out v="@{#count,,000}" /> </td> <td> <t:out v="@{#index,,'idx-00'}" /> </td> <td> <t:out v="@{.code,???,000}" /> </td> <td> <t:out v="@{.city,'no city'}" /> </td> <td> <t:out v="@{.phone,'???'}" /> </td> </tr> </t:iterate> </table> Telosys framework - Symbolic variables ( Laurent Guérin )

  10. Use cases • Populate combo box items from a list of beans : • Populate combo box items from a DataSet : • It's the same for list box, with tags <t:listbox … > and <t:listitems ..> <t:combobox id="ag1" x="80" y="40" value="2" > <t:comboitems list="mylist" id="agency_item" cl="myclass" style="color:red" title="The title @{#count}" value="@{.code}" txt="@{.code} - @{.name} (@{#count})(@{#index})"/> </t:combobox> <t:combobox id="Ag999" x="80" y="40" value="003" > <t:comboitems list="MYDATASET" style="color:@{3,black}" value="@{.2,000,'000'}" txt="@{.2,000,'000'} - @{.1,???} (@{#count})(@{#index})"/> </t:combobox> Telosys framework - Symbolic variables ( Laurent Guérin )

  11. THE END

More Related