The getObject method is the most commonly used method for retrieving an object from within the repository. When using this method, remember that you are fetching actual (Java) objects. To access attributes from that object, you must wrap the object in an invocation that calls the object’s getter methods. Because each object uses particular get operations, refer to the individual object’s Javadoc for more detail.
When working with the WSUser object, you can use the WSUser object’s toHashMap() method. This method converts the object into a GenericObject, which is equivalent to a Java HashMap, as shown in the following example:
<set name=’wsUserObj’> <invoke name=’getObject’> <!-- typically, a value such as :display.session would go here; instead, call the handy rule --> <rule name=’Get Context’/> <s>User</s. <s>SamUser</s> </invoke> </set> <set name=’wsGenericObj’> <invoke name=’toHashMap’> <ref>wsUserObj</ref> </invoke> </set>
To retrieve the accountId from the WSUser object, use the following
<invoke name=’getAccountId’> <ref>wsUserObj</ref> </invoke>
However, when you are working with a user, this method can become tedious. The same thing via the WSUser object now converted into a GenericObject:
Basically, GenericObjects, such as views, can be much easier to work with than the WSUser object. Consider checking out the view of the associated object when dealing directly with the object is cumbersome.
Some operations will result in the repository locking the underlying PersistentObject. Typically, methods that begin with the phrase “checkout” will lock the object, “checkin” will unlock it), and methods that being with “get” will not lock the object.