Magnolia CMS modules

Magnolia CMS Modules

by Devexperts

Child pages
  • dx-magnolia-ocm

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example bean class:

 

Code Block
@Node(jcrType = BaseOCM.MGNL_CONTENT_NODE_TYPE) 
public class FinancePlan extends BaseOCM {
    public enum PricingModel {
        FREE, PAID
    }

    @Field 
    private String name;
    @Field
    private PricingModel pricingModel;
    @Field(jcrDefaultValue = "false")
    private boolean active;
    @Bean
    private Money price;

    public FinancePlan() {}

    public PricingModel getPricingModel() {
        return pricingModel;
    }

    public void setPricingModel(PricingModel pricingModel) {
        this.pricingModel = pricingModel;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public boolean getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Money getPrice() {
        return price;
    }

    public void setPrice(Money price) {
        this.price = price;
    }

}

Note the following:

  • The class is inherited from BaseOCM class which contains path and uuid fields. 
  • JCR type is explicitly specified. By default, nt:unstructured type is used, so the type should be specified in most cases.
  • Each field and bean has its own getter and setter.
  • You may specify default values for fields.
  • Enum is supported as field type.
License 

The library is released under GPL license. Contact us if you need this module under different license.