Friday, June 8, 2012

ATG Basics : Inserting ATG Servlet Beans

Inserting ATG Servlet Beans



You can use the Document Editor to insert ATG servlet beans. For example, you can insert a ForEach servlet bean as follows:


1.    Place the cursor in the body of the document where you wish to insert the servlet bean.

2.    From the Insert menu, select Insert Servlet Bean. The Insert Servlet Bean dialog box opens.

3.    Select Servlet Beans from the Categories list, then select ForEach from the Components list. 
       Click OK.

4.    In the Insert ForEach Servlet Bean wizard, click the “...” button.

5.    In the Choose a Dynamic Value dialog box, enter the array property whose elements you wish to 
       retrieve.       
    
      For example:

      bean="/samples/Student_01.subjects

6.   Click OK, and then click Next in the wizard.

7.   In the Specify output text box, specify the output to display for each property element
     
      For example:

      <li><dsp:valueof param="element"></dsp:valueof>

8.    Click Next.

9.    In the Specify outputStart text box, enter the text to display before loop execution begins. 
      
       For example:

       <p>The student is registered for these courses:

10.  Click Next.

11.  Leave the Specify outputEnd text box blank, and click Next.

12.  Leave the Specify empty text box blank, and click Finish.


The document should now contain these tags:



<dsp:droplet name="/atg/dynamo/droplet/ForEach">

  <dsp:param bean="/samples/Student_01.subjects" name="array"/>
      <dsp:oparam name="outputStart">
            <p>The student is registered for these courses:
      </dsp:oparam>

      <dsp:oparam name="output">
            <li><dsp:valueof param="element"></dsp:valueof>
      </dsp:oparam>

</dsp:droplet>



Importing servlet beans




To make a servlet bean visible in the Dynamic Element Editor, import the component into the page with dsp:importbean.

 For example:

<dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>


Importing the servlet bean lets you refer to it without including the entire path, as in this line:

<dsp:droplet name="ForEach">

By importing a Nucleus component into the pageContext with the dsp:importbean tag, other (non-EL) references to that component can exclude the Nucleus address.

No comments:

Popular Posts