Search This Blog

Thursday 19 March 2015

Going deeper with floating fields

Floating fields allow variable text to be inserted within a text object.  A floating field is referenced within a rich text field using XFA extension to the xHTML <span> element, e.g.

As inserted by the LiveCycle Designer Insert ... Floating Field command you will get something like this in the XML Source

<span xfa:embedType="uri" xfa:embedMode="raw" xfa:embed="#floatingField007456"/>

The full XFA syntax for a floating field is;

<span xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
      xfa:embedType="uri | som"
      xfa:embed="<SOM expr> | <uri>"
      xfa:embedMode="raw | formatted"/>

embedType

When the embedType has a value of "uri" then the embed value will be the id of the floating field, prefixed with a "#" symbol.

But you can see from the syntax that there are some other options available.  Sometimes we might create a floating field bind it to our data connection just to display the value embedded in some text.  Say the floating field was bound to $data.formData.firstName then we could change our span element to reference the data connection directly, in which case we don't need the floating field at all.

Another situation you may need to use a SOM expression in an embedded field is when you have multiple levels of repeating data, such as a list of countries within which we have a list of cities


If I wanted to use a floating field to display the country element within the repeating city element, there is no way Designer can make the reference.  Designer will give you a binding expression like $record.counties.country, which will always return you the first country.  In this case we can again change the embedType to "som" but use a form object SOM expression, something like;

<span xfa:embedType="som" xfa:embedMode="raw" xfa:embed="countries.country"/>

This will resolve to the form object with the SOM expression countries.country, which should be the right country for the city we are processing.

embedMode

By default the embedMode is set to "raw", which means only the floating fields value is inserted, all font formatting is taken from the surrounding text.  A value of formatted for embedMode means the font attributes of the inserted text are taken from the inserted field, which can be useful if we need to dynamically update them as in this sample, FloatingFields.pdf.

No comments:

Post a Comment