You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Cesar Lugo <ce...@sisorg.com.mx> on 2015/10/15 19:54:36 UTC

Contributions

Hello. I am trying to create a custom list that shows within an object form.
I understand this is called a Contribution in the Apache ISIS programming
model. I tried with the code below(trying first with a simple list returning
all instances). The Action with the list is not shown, nor the list. Only
the AddItem list is shown. Am I missing something to make it properly work?

 

@DomainService(repositoryFor = ItemCategory.class,
        nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)

public class ItemCategoryContributions {



    //region > allItems (action)
    @Action(semantics = SemanticsOf.SAFE)
    @ActionLayout(contributed = Contributed.AS_ASSOCIATION)
    @CollectionLayout(render = RenderType.EAGERLY)
    public List<Item> allItems() { return
container.allInstances(Item.class);}
    //endregion





    //region > addItemCategory (action)
    public static class CreateDomainEvent extends
ActionDomainEvent<ItemCategoryContributions> {
        public CreateDomainEvent(final ItemCategoryContributions source,
final Identifier identifier, final Object... arguments) {
            super(source, identifier, arguments);
        }
    }

    @Action(
            domainEvent = CreateDomainEvent.class
    )
    @MemberOrder(name="itemCategories",sequence = "1")
    public ItemCategory addItemCategory(
            final @ParameterLayout(named="Business") Business business,
            final @ParameterLayout(named="Item Id") String itemCategoryId,
            final @ParameterLayout(named="Name") String name,
            final @Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named="Description", multiLine = 4) String description
    )
    {
        final ItemCategory obj =
container.newTransientInstance(ItemCategory.class);
        obj.setBusiness(business);
        obj.setItemCategoryId(itemCategoryId);
        obj.setName(name);
        obj.setDescription(description);
        obj.setActivationTime(clockService.nowAsDateTime());
        obj.setStatus(ItemStatus.ACTIVE);
        container.persistIfNotAlready(obj);
        return obj;
    }
    //endregion

    //region > injected services

    @javax.inject.Inject
    DomainObjectContainer container;

    @Inject
    private ClockService clockService;


}

 

 

 



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus