telosys-symbolicvar-v1.0

Upload: laurent-guerin

Post on 07-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    1/10

    Telosys 1

    Symbolic Variables

    Laurent Gurin / v 1.0 / 2009 - May

    Telosys framework - Symbolic variables ( Laurent Gurin ) 2

    What are symbolic variables ?

    The symbolic variables are a set of predefinedexpressions for accessing server information in aTelosys tag attribute

    The variables are replaced by their value when theJSP is called

    Syntax : @{ variable_name, default_value, format }

    Examples :

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    2/10

    Telosys 2

    Telosys framework - Symbolic variables ( Laurent Gurin ) 3

    What are symbolic variables ?

    The symbolic variables are completelyindependent of the standard JSP ExpressionLanguage ( "EL" ). They can be used even in oldJava 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 :

    id namevalue txt valueoff title zone checkedcl style selecteddisabled readonly

    Telosys framework - Symbolic variables ( Laurent Gurin ) 4

    Symbolic variables : predefined values

    Predefined names : "#xxx"

    Session & User @{#session-id} the current session id

    @{#user-login} the current user login

    @{#user-language} the current user language

    @{#user-role} the current user role URL & URI

    @{#webapp-url} "http://localhost:8080/appli/"

    @{#webapp-uri} "/appli/"

    @{#screenmap-url} "http://localhost:8080/appli/screenmap"

    @{#screenmap-uri} "/appli/screenmap"

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    3/10

    Telosys 3

    Telosys framework - Symbolic variables ( Laurent Gurin ) 5

    Symbolic variables : predefined values

    HTTP request parameters : @{#paramcount} number of parameters

    @{#param-xxx} value of the "xxx" parameter

    Iterations : @{#count} the current count value ( from 1 to n )

    @{#count-parity} "even" or "odd"

    @{#index} the current index valuefrom index-base (0 by default) to n

    @{#index-parity} "even" or "odd"

    Telosys framework - Symbolic variables ( Laurent Gurin ) 6

    Symbolic variables : predefined values

    Screen Context : @{#context-id} 0 to N

    @{#context-name} "MYSCREEN" ( from ScreenContext registry )

    Screen Map ( from "screens.xml" ) : @{#screen-name} "S002"

    @{#screen-type} "html" or "xul"

    @{#screen-path} "/screen/tpl/html/model1.jsp"

    @{#screen-body} "S002.jsp"

    @{#screen-body-path} "/screen/S002.jsp"

    @{#screen-css} "S002.css"

    @{#screen-css-path}

    @{#screen-js} "S002.js"

    @{#screen-js-path} "/screen/script/S002.js

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    4/10

    Telosys 4

    Telosys framework - Symbolic variables ( Laurent Gurin ) 7

    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 "currentbean" ( the "." in first position defines an attribute )

    @{agency} string value of the bean "agency"( using the "toString" method of the bean )

    Example :

    Telosys framework - Symbolic variables ( Laurent Gurin ) 8

    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 thefollowing scopes order : 1 screen-context data element ( 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 aservice call

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    5/10

    Telosys 5

    Telosys framework - Symbolic variables ( Laurent Gurin ) 9

    Symbolic variables and services

    Special bean name : "RENDERER-BEAN" ( or "RENDERER_BEAN" )

    points the "service result" object( this special name is usable only in a service renderer )

    Example :

    Any other bean can be used in a classical way if

    the service expose it in the request scope

    Agency result = new Agency();

    serviceResponse.setResult(result);

    Agency agency = new Agency();

    serviceResponse.expose("agency", agency);

    Telosys framework - Symbolic variables ( Laurent Gurin ) 10

    Symbolic variables for List

    Size of a Collection, VOList or DataSet : @{mylist.size} list size

    Example ( list with a VOList ) :

    element(s) in the list :

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    6/10

    Telosys 6

    Telosys framework - Symbolic variables ( Laurent Gurin ) 11

    Symbolic variables for DataSet

    DataSet cells can be accessed with a numbercorresponding to the column number of thecurrent 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 ) :

    Default value & format

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    7/10

    Telosys 7

    Telosys framework - Symbolic variables ( Laurent Gurin ) 13

    Symbolic variables - Default value

    If the symbolic variable is not found If there is a default value : it is used

    Else : a void string is returned ( "" )

    The default value is located at the 2nd positionexamples : @{myint,123} "123" if not found

    @{myint,123,000000} "123" if not found

    @{mystr,'bla bla'} "bla bla" if not found

    @{mystr,bla bla} likewise (the quotes are optional)

    When the default value is used, it is returned"as is", the format is not applied on a default value

    Telosys framework - Symbolic variables ( Laurent Gurin ) 14

    Symbolic variables - Format

    The format is located at the 3d positionexamples : @{myint,,00000} "00123" for 123

    @{myint,not found,000000} likewise

    @{mydate,,'yyyy-MM-dd'} "2008-03-30" @{mydate,,yyyy-MM-dd} likewise

    (the quotes are optional)

    Without format, the "toString" method of theobject is used

    The format is not applied on the default value

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    8/10

    Telosys 8

    Telosys framework - Symbolic variables ( Laurent Gurin ) 15

    Symbolic variables - Format

    Boolean object format : Without format boolean returns "true" or "false"

    Format syntax : "value-if-true|value-if-false"examples : @{mybool,,Yes|No}

    @{mybool,,Black|White}

    @{mybool,,1|0}

    Number object format(Integer, Long, Double, BigDecimal, BigInteger, )

    If the format contains "|"

    the "java.text.ChoiceFormat" is used Else the "java.text.DecimalFormat" is used

    Date object format The "java.text.SimpleDateFormat" is used

    Seethe

    javadoc

    Use cases

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    9/10

    Telosys 9

    Telosys framework - Symbolic variables ( Laurent Gurin ) 17

    Use cases

    Print a bean attributes :

    Using "with/without" tag :

    Bean not found

    Code

    Name

    City

    Telosys framework - Symbolic variables ( Laurent Gurin ) 18

    Use cases

    Iterate on a list :

  • 8/6/2019 Telosys-SymbolicVar-v1.0

    10/10

    Telosys 10

    Telosys framework - Symbolic variables ( Laurent Gurin ) 19

    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 and

    THE END