The remainder of this appendix describes how to use the MapXMLBuilder class through several illustrative examples. Note that in the JSP fragments ${FH} is a variable created elsewhere on the page; its value is the full Nucleus pathname of the form handler.

Simple Tags

The first example generates this relatively simple strprop tag:

<strprop op="equal" name="childSKU.color">
  rose
</strprop>

The JSP looks like this:

<-- Create the <strprop> tag -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.tagname"
  value="strprop">

<-- Add the <strprop op="equal"> attribute -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.attr.op"
  value="equal">

<-- Add the <strprop name="childSKU.color"> attribute -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.attr.name"
  value="childSKU.color">

<-- Finally, the <strprop> tag's body -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.body"
  value="rose">

Note that myTag is an arbitrary string identifier for a given tag on the page. This value is not rendered in the XML output; it merely serves as a way to distinguish between multiple tags at the same level.

The JSP fragment above illustrates how the basic components of any tag are specified on the page:

identifier.tagname

The input tag’s value attribute specifies the name of the generated XML tag. There must be exactly one tagname entry.

identifier.attr.attributeName

The input tag’s value attribute specifies the value of an XML tag attribute using the format attributeName="value". There can be at most one attr entry, and zero or more attr.attributeName entries.

identifier.body

The input tag’s value attribute specifies the value for the body of the generated XML tag.

Nested Tags

This example illustrates the generation of two property constraints tags nested within a Boolean <and> tag:

<and>
  <strprop op="equal" name="childSKU.color">
    rose
  </strprop>
  <numprop op="lesseq" name="childSKU.price">
    30.00
  </numprop>
</and>

The JSP looks like this:

<-- Create the outer <and> tag -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.andTag.tagname"
  value="and">

  <-- Create the nested <strprop> tag -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.strp.tagname" value="strprop">

  <-- Add the <strprop op="equal"> attribute -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.strp.attr.op" value="equal">

  <-- Add the <strprop name="childSKU.color"> attribute -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.strp.attr.name"
    value="childSKU.color">

  <-- Add the <strprop> tag's body -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.strp.body" value="rose">

  <-- Create the nested <numprop> tag -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.nump.tagname" value="numprop">

  <-- Add the <strprop op="lesseq"> attribute -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.nump.attr.op" value="equal">

  <-- Add the <strprop name="childSKU.price"> attribute -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.nump.attr.name"
    value="childSKU.price">

  <-- Finally, the <strprop> tag's body -->
  <dspel:input type="hidden"
    bean="${FH}.documentSetsBuilder.tags.andTag.nump.body" value="30.00" >

Things to note from this example

Conditionally Rendered Tags

There may be times when the decision to generate one or more tags cannot be made when the page is rendered. Specifically, it may be undesirable to generate tags meant to capture user input when no input is provided. In the example below, if the user does not enter a value for the product color, childSKU.color, then the constraint tag should not be generated.

The conditionally generated strprop tag:

<strprop op="equal" name="childSKU.color">
  value from user input, if provided
</strprop>

The JSP:

<-- Create the <strprop> tag -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.tagname"
  value="strprop">

<-- Add the <strprop op="equal"> attribute -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.attr.op"
  value="equal">

<-- Add the <strprop name="childSKU.color"> attribute -->
<dspel:input type="hidden" bean="${FH}.documentSetsBuilder.tags.myTag.attr.name"
  value="childSKU.color">

<-- The user input field, in this case the <strprop> tag's body -->
<dspel:input type="text" bean="${FH}.documentSetsBuilder.tags.myTag.body">

<-- The conditional generation option: generate only if user enters a value for
  the tag body -->
<dspel:input type="hidden"
  bean="${FH}.documentSetsBuilder.tags.myTag.opts.generate" value="ifvalue:body">

Things to note from this example:

 
loading table of contents...