You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Dan Haywood (JIRA)" <ji...@apache.org> on 2014/07/18 12:48:04 UTC

[jira] [Commented] (ISIS-801) Action method taking domain object paramater gets triggered automatically whenever instances of that object type is accessed

    [ https://issues.apache.org/jira/browse/ISIS-801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14066262#comment-14066262 ] 

Dan Haywood commented on ISIS-801:
----------------------------------

Hi Ranganath,

As you've realized, I think, this service action :

public OmPermission createSitePermission(final @Named("Choose a site") OmSite site)

accepts a single entity and is non-void, which means it ends up being contributed as a property.  When the contributee entity (OmSite) is rendered, the contributed property is eagerly executed, resulting in the unwanted side-effect.

I think the solution here is for Isis only to contribute properties/collections for actions that have no side-effects, ie which are @ActionSemantics(Of.SAFE).   Should be easy enough to do.

Thx for raising this.

Dan


> Action method taking domain object paramater gets triggered automatically whenever instances of that object type is accessed
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ISIS-801
>                 URL: https://issues.apache.org/jira/browse/ISIS-801
>             Project: Isis
>          Issue Type: Bug
>          Components: Core, Viewer: Wicket
>    Affects Versions: core-1.5.0
>            Reporter: Ranganath Chittari
>            Assignee: Dan Haywood
>            Priority: Minor
>             Fix For: core-1.7.0
>
>
> I have application security service which creates permission to manage particular entity(OmSite). Its action method is:
>     @Bookmarkable
>     @MemberOrder(sequence = "9")
>     @Named("Create Site Permission")
>     public OmPermission createSitePermission(final @Named("Choose a site") OmSite site) {
>         final OmPermission obj = newTransientInstance(OmPermission.class);
>         obj.setPermission(SecurityUtil.formatSitePermission(site.getOrgId(), site.getSiteId()));
>         obj.setSite(site);
>         persistIfNotAlready(obj);
>         return obj;
>     }
> As you can see this method takes OmSite instance to create a permission to that instance. And OmPermission has foreign key to OmSite. This action is displayed in service menu and its working fine.
> But the problem I am facing is when I access the list of OmSite objects in other UI pages.  This action method is getting triggered automatically and inserts bulk OmPermissions for all those List<OmSite> objects.
> This action method createSitePermission should be invoked only if it is clicked manually, but it gets triggered automatically whenever OmSite is accesed in some other places.
> For ex:
> an action that returns a list of these OmSite, 
> when OmSite is in a collection of some other entity,
> When new OmSite is created.
> Workaround for this issue is annotate @NotContributed  to that action method, it will prevent from invoking this method whenever its parameter instance is accessed.
> BR
> Ranganath Varma
> Could you please look into this issue.



--
This message was sent by Atlassian JIRA
(v6.2#6252)