top of page
The PC Tech

Java Script to Make Fields Visible and Invisible Depending on Checkbox Selection in an AEM-generated Static PDF

Updated: Nov 6




Situation:

Need to hide or display text and image depending on if the document will be printed on letterhead paper.

The problem arose because there was only one field, one line of text, and a logo. While the field would become invisible on checkbox selection, the other items would not.

Solution:

Make all of the objects, fields because, in a static PDF, it is possible to make fields invisible, just not other objects.

Field Construction Details:

  1. Place the clear button, instructions, and checkbox selections outside of the standard printing area (at the very top of the AEM workspace). Make sure any text which may need to be printed is well within the standard printing area.

  2. Wrap all object to be made invisible with a subwrap, rather than referencing them individually.

  3. For images, such as logos, change from Image type to Image Field Type.

  4. For Static text:

    • Change from Text type to Text Field type, remove the caption, and insert the static text as the Default under Object, Value.

    • Set the type for this field as Read Only to keep users from changing the text but still allow screen reader software users to have the text announced.

    • For all fields that must become invisible, set the Object Presence to Visible, screen only.

    • Provide appropriate Alt text for this static field (the same as the default text itself.

Scripting Details for the Checkbox Selections:

In this example, visibility is driven by a checkbox selection.

For the Checkbox which makes the objects visible, on the Click Event make the other checkbox rawValue zero and the Node at the sub level visible.

For the Checkbox which makes the objects invisible, on the Click Event make the other checkbox rawValue zero and the Node at the sube level, visible.

You can use relative references.

Example for the visible syntax:

this.resolveNode("name of subwrap").presence = "visible";

Example for the invisible syntax:

this.resolveNode("name of subwrap").presence = "invisible";


Note if the object path has more than one subwrap, you must use all the subwraps in the name with a period between each.

14 views0 comments

Recent Posts

See All

Comentarios


Los comentarios se han desactivado.
bottom of page