Developing with the SDK > Using CSS Syntax in the Style Sheet > Applying CSS To Java Objects > CSS Recursion

You are likely to want to specify a Java object as the value of a declaration. A simple convention allows you to recurse in the style sheet, that is, to define a new Java object which has the same style sheet but is unrelated to the current data model.

@# Construct

Prefix the value with @# to create new Beans when required as shown in Code Sample 3.5.

form { 
      date : "@#dateBean" ; 
      title : "CSS rules" ;
}
Subobject#dateBean { 
      class : 'java.util.Date' ; 
      time  : '23849291' ;
} 

Code Sample 3.5 Creating a Bean in a Declaration

The @# operator extends the current data model by adding a dummy model object as the child of the current object. The object ID of the dummy object is the remainder of the string, beyond the @# operator. The type of the dummy object is Subobject. The dummy object inherits CSS classes and attributes from its parent.

The CSS engine creates and customizes a new subobject according to the declarations it finds for the dummy object. This means, in particular, that the Java class of the subobject is determined by the value of the class property. The newly created subobject becomes the value of the @# expression. In the declarations for the subobject, attribute references through the @ operator refer to the attributes of the parent object.

Once the subobject is completed, the previous model is restored so that normal processing is resumed.

In Code Sample 3.5, a java.util.Date object is created, with the time property set to 23849291. This new object is assigned to the date property of the form object.

@= and @+ Constructs

There are two refinements of the @#ID operator:

The need for these refinements arises from a performance issue. The @#operator creates a new object each time a declaration is resolved. Usually a declaration is applied whenever a property changes. Under certain circumstances, the creation of objects may lead to expensive processing, so ILOG JViews Diagrammer provides an optional mechanism to minimize the creation of objects during property changes.

@| Construct

A CSS declaration value starting with @| is interpreted as an expression (see Expressions).

@ Construct

A CSS declaration value that is exactly @ means cancel the property setting made in a previous rule. This construct is useful to prevent a property from being modified, especially when the default value is unknown. For example:

node {
   width : 23 ;
}

node.fixed {
   width : @ ;
}

Code Sample 3.6 Canceling a Property Setting

These two rules say that the width property value should be set to 23, unless the node has the CSS class fixed. Without the @ ability, the default value of width would have to be written down in the CSS.