Logic Tags


This library provides a basic set of logic tags.

Many of these tags have a scope argument. The valid values for the scope argument are "tag", "portlet request", "http request", "session", "persistent session", "application". NOTE: These values are not case-sensitive, but it is considered a best practice to use all lower case.

Various tags also set editable shared variables as part of their execution. If a variable with the same name already exists, it will be overwritten. If the pre-existing variable is not editable, then the tag will fail. Variable names cannot contain the reserved character '.'.

Tag Library Information
Namelogic
Version1.1
 

Tag Summary
appendhierdataThis tag is used to create hierarchical data by appending child data or adding new child data if none exist. Use this tag to append data from the data attribute to the target location specified by the index attribute. If no children exists, the data is added as children. An index attribute with no value creates a new hierarchical data structure.The example below appends the data named "communityPages" to "topCommunities" at index 0,2. If "topCommunities" contains a list of Communities and their Subcommunities and communityPages contains a list of Community Pages this tag adds Community Pages in "communityPages"to the 3rd Subcommunity (2 is the 3rd element in 0 based index) of the first top level Community. In the example, the pt:childkey attribute specifies that you are adding data to Community Pages; this attribute is not needed when appending a list of subcommunities as it is the default child type for communities.
boolexprThis tag evaluates a boolean expression and stores the result as a boolean in memory. It is designed to work with the logic.if tag.
collectionlengthThis tag evaluates the length of a collection and stores the result in memory.
collectionThis tag creates a data collection (a collection of variables, such as data objects) and stores it as an editable shared variable using the key supplied in the tag attributes. It is stored in in Portlet Request scope by default. The variable is only stored after this tag is finished processing it's contents. The collection tag does not append to a pre-existing collection, but will just overwrite it instead. To clear a collection, simply use this tag with no data or variable tags inside it. This collection variable can be used with the foreach tag. This tag will process nested tags to populate the data collection, but will not output any HTML. This tag also creates a temporary editable shared variable stored using the key collection. Be careful not to create a collection with different types of variables, such as string variables and data objects.
concatThis tag concatenates up to ten values into one and sets the new value in a variable with a specified name. The first two values are required in order to perform a concatenation.
containsexprThis tag checks if an collection contains a specific data element and sets a specified variable to true or false. It is designed to work with the logic.if tag.
dataThis tag creates a data object (a collection of name value pairs) and stores it as an editable shared variable using the key supplied in the tag attributes. This tag can also be used inside the collection tag, in which case the key attribute is not necessary and the name value pairs will be stored directly in the parent collection. The key attribute is required otherwise. The XML attributes (non pt: attributes) for this tag are used as name value pairs for the data object. It is stored in in Portlet Request scope by default. This variable can be used in attribute value replacement or with the value tag.
existexprThis tag evaluates whether a shared variable exists and stores the result as a boolean in memory. It is designed to work with the logic.if tag.
foreachThis tag allows you to loop over data collections stored in memory as XPArrayLists. The data collection should not be modified while looping to avoid unpredictable side effects. The index value in a foreach loop is key+index (i.e. $varindex).
iffalseThis tag is displayed if the surrounding logic.if tag evaluates to false.
ifThis tag evaluates an expression and then displays either the logic.iftrue or logic.iffalse tag contents.
iftrueThis tag is displayed if the surrounding logic.if tag evaluates to true.
intexprThis tag evaluates an integer expression and stores the result as a boolean in memory. It is designed to work with the logic.if tag.
intopsThis tag evaluates an integer expression and stores the result as an integer in memory.
replacehierdataThis tag is used to create or modify hierarchical data by replacing child nodes with new data collection.Use appendhierdata tag to create new children or append data to existing children.The example below replaces children of "topCommunities" at location 0,2 with the data in "communityPages" tag variable. If topCommunities contains a list of communities and their Subcommunities and "communityPages" contains a list of Community pages, the tag replaces existing Community Pages in the 3rd Subcommunity (2 is the 3rd element in 0 based index) of the first top level Community. In the example, the pt:childkey attribute specifies that you are inserting data to Community Pages; this attribute is not needed when inserting a list of subcommunities, because that is the default child type for Communities.
separatorThis tag allows you to display a separator in between elements of a foreach loop without displaying an extra one at the end. Content in this tag will be displayed for every iteration of the loop except the last.
sortThis tag allows you sort data collections stored in memory as XPArrayLists. The property attribute will be used to construct the sorted list. If the property doesn't exist for certain entries in the list, those entries will then be ordered at the end of the list in alphabetical order based on their name.

This tag does not display the contents of the tag and should only be used as a singleton tag (i.e. <pt:logic.sort/>), rather than as a tag with both an open and close tag.

stringexprThis tag evaluates whether or not two strings are equal and stores the result as a boolean in memory. Case must match. It is designed to work with the logic.if tag.
appcacheThis tag provides caching of data set by data tags. The difference between this tag and the sessioncache tag is that this tag caches data on the application, meaning the data is shared between multiple users, while the sessioncache tag caches data on each user's session where the data is only accessible to each individual user. Typical use of the appcache tag would be to cache data for all users in a Community or a Community page. The sessioncache tag caches data on each user's session.
Note that there is no access control on cached data. Do not cache data tags returning security filtered objects. WCI objects such as Communities, Portlets, or Pages are all secured on a per user basis. Caching security filtered data bypasses security checks and all users using the cached data see the view of the user who happened to add the cache entry.
Also note that most data tags do not need to be cached. Data tags in the ptdata tag library already use server-side cached data. Suitable data tags to cache are ones that execute database or search queries every time they run and where the data is not security filtered. For example custom properties on a Community that every user has access to or a custom list of Communities visible to every user.
To cache a data tag, define it normally and then nest it inside of the cache tag. Then set the data and datascope attributes of the cache tag with the data key and data scope of the data tag. On the cache tag, define expiration duration for the cache entries and a contextid. To cache data in a Community, pass in current Community id as the contextid value. For a page, use the Page id.
sessioncacheThis tag provides caching of data set by data tags. The difference between this tag the other cache tag, appcache tag, is that this tag caches data on a per user basis and the data is cleared after a user logs off, while the appcache tag caches data shared between multiple users and persists across user sessions.
Typical use of this tag would be to cache user specific data such as User Info data or custom properties added to users.
Note that most data tags do not need to be cached. Data tags in the ptdata tag library already use server-side cached data. Suitable data tags to cache are ones that execute database or search queries every time they run. For example custom properties on a Community that every user has access to.
To cache a data tag, define it normally and then nest it inside of the cache tag. Then set the data and datascope attributes of the cache tag with the data key and data scope of the data tag. On the cache tag, define expiration duration for the cache entries and a contextid. To cache data in a Community, pass in current Community id as the contextid value. For a page, use the Page id.
valueThis tag evaluates the attribute as a Transformer Tag attribute and displays the value.

This tag does not display the contents of the tag and should only be used as a singleton tag (i.e. <pt:logic.value/>), rather than as a tag with both an open and close tag.

variableThis tag stores an editable shared variable using the key and value supplied in the tag attributes. This tag can also be used inside the collection tag, in which case the key attribute is not necessary and the name value pairs will be stored directly in the parent collection. The key attribute is required otherwise. It is stored in Portlet Request scope by default. This variable can be used in attribute value replacement or with the value tag.
 


Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-3 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.