You can import a Nucleus component with dsp:importbean, which is modeled after Java class imports:

<dsp:importbean bean="Nucleus-path" [var="attr-name" [scope="scope-spec"] ]

After a component is imported, references to it can omit its path and use its name only.

For example, the following tag imports the component /samples/Student_01 and creates the EL variable student:

<dsp:importbean bean="/samples/Student_01" var="student"/>

This tag accomplishes two tasks:

  • Imports the Student_01 component into the pageContext so non-EL references to Student_01 can exclude its full Nucleus path absolute component Nucleus address and just use the shorthand name (Student_01). For example:

    My favorite subject is<dsp:select bean="Student_01.subject">
    <dsp:option value="math">Math</dsp:option>
      <dsp:option value="music">Music</dsp:option>
      <dsp:option value="physicalEducation">Phys Ed</dsp:option>
      <dsp:option value="history">History</dsp:option>
    </dsp:select>

  • Makes the Student_01 component available to EL. For example, other tags might use this feature as follows:

    My name is <c:out value="${student.name}"/>

By default, the student variable is set to page scope, which makes it accessible to any EL-enabled resources on the same page. You can define a larger scope for the student variable by setting the scope attribute to request, session, or application.

Note: dsp:importbean can import any JavaBean or Dynamic Bean component into a page; however, this tag can only set standard JavaBeans to an EL variable and make them accessible to EL. To make Dynamic Beans visible to EL expressions, use dsp:tomap.

 
loading table of contents...