Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      The Component Tag Language

      Declaring user interface controls

      Table of Contents

      Component Tag Language

      The component tag language eases the definition of user interface components within our templates.
      Component tag language offers an extendible XML-based syntax that is interpreted by the framework and replaced by client-side specific code in run-time (i.e. XHTML + javascript code).

      Note that components can be declared by using the tag language just in template based views. Out of the box Lion uses a view based on Smarty templates to render the user interface.

      Declaring Components

      The component tag has the following syntax:

      <comp:tag
          [name="component-name"]
          [
              property = value
          ]*
      />

      where

      • tag is a name identifying the component that the tag represents to (i.e. commandbutton, inputbox, ...).
      • component-name is a name to identify a concrete component instance. This parameter is optional. If no names are supplied, a default one will be assigned to the component.
      • The list of pair property-value is a set of initial values to setup a component.

      i.e.

      1. <comp:commandbutton name="myButton" caption="Click on me!"/>
      2. <comp:inputbox name="myInputBox" value=""/>
      In this example, we have defined 2 components, a command button and an input box.
      An yes, components are defined within the template content as part of.


      Defining Containers

      A component can be also defined by ussing a pair begin-end tags. It allows to close a piece of template content:

      <comp:tag
          [name="component-name"]
          [
              property = value
          ]*
      >

      ...

      </comp:tag>

      In that case, the content closed by the component can also contain other component tags. In that case, the component acts as container.

      i.e.

      1. <html>
      2. <head>
      3.   <title>Component rendering engine sample</title
      4. </head>
      5. <body>
      6.  
      7. <comp:form name="myTabPane">
      8.  
      9.   Login: <comp:inputbox name="login"/>
      10.   
      11.   Password: <comp:inputbox name="password" type="password"/>
      12.   
      13.   <comp:commandbutton name="submit" type="submit" caption="Login!"/>
      14.  
      15. </comp:form>
      16.  
      17. </body>
      18. </html>


      Defining Properties

      Finally, a component can define properties within the enclosed area by ussing the comp-property tag.
      This is really usefull to assign components as property for other components.

      The syntax for ussing the comp-property is the following one:

      <comp-property name="property-name">
          (property value goes here)
      </comp-property>

      i.e.

      1. <html>
      2. <head>
      3.   <title>Component rendering engine sample</title
      4. </head>
      5. <body>
      6.  
      7. <comp:commandlink name="about_us">
      8.   <comp-property name="caption">
      9.     <comp:resource key="about_us_i18n_literal"/>
      10.   </comp-property>
      11. </comp:commandlink>
      12.  
      13. </body>
      14. </html>
      In this example we are using the comp-property tag to assign a component to the caption property.

      It's really important to note that we can not use template placeholders as attribute values within component tags, because the template is processed before the component render engine parses it.

      However, Lion offers a workarround by ussing the tag comp-property as we have seen. i.e.:

      1. <html>
      2. <head>
      3.   <title>Component rendering engine sample</title
      4. </head>
      5. <body>
      6.  
      7.   <!-- Assign a placeholder to a property within the  
      8.        comp tag DOES NOT WORK: -->
      9.   <comp:commandlink name="about_us" caption="{$about_us_literal}">
      10.  
      11.   <!-- Assign a placeholder to a property by ussing the
      12.        comp-property tag WORKS: -->
      13.   <comp:commandlink name="about_us">
      14.     <comp-property name="caption">{$about_us_literal}</comp-property>
      15.   </comp:commandlink>
      16.  
      17. </comp:tabpane>
      18.  
      19. </body>
      20. </html>
      In this example, we can not assign directly the placeholder about_us_literal as an attribute value, but we have the workarround of ussing the comp-property tag for the same purpose.


      The The Hello World Deluxe is a simple but practical tutorial regarding components and event handlers.