Loading Beans

One of the easiest methods of accessing a bean in Mura is using the common helper method loadBy(). All of the main Mura beans (content, user, feed, category) have this method.

For example, these main beans can be loaded using:

  • Content Bean: (optional properties: contentID, contentHistID, fileName, remoteID, title)
  • Feed Bean: (optional properties: feedID, name, remoteID)
  • User Bean (optional properties: userID, username, groupName, remoteID)
  • Category Bean: (optional properties: categoryID, name, remoteID)

How To

What happens if a loadBy parameter has multiple matches:

If the parameters sent to a loadBy() request have more than one match then the method will return an array of beans.

For example, if the following request had more than one matches:

In this case "loadByRemoteID" could be an array of contentBean objects, while the "content" variable would the contentBean in the first position of the array.

bean.getValue({Property});

This existing method can access both base bean values as well as any extended attributes. Simply pass in the variable name for the attribute and your value will be retrieved. If the value isn't found, it will return as an empty string.

Examples:

Get a common field:

Get extended attribute data (see next section):

bean.setValue({property}, {property value});

This existing method has been expanded to allow the setting of extended attributes; no more needing to figure out extend set id's, etc.

Example:

Set extended information:

bean.save()

The save method is quite simple. If you want to save the data in the bean to the database (add or update), just call this method.

Example:

delete()

As long as the data is persistent, when you call this method, it will delete the associated record from the database.

Example: