[help] actions on entity selections and on entity detail

8 posts / 0 new
Last post
Marc
Offline
Joined: 07/08/2009
[help] actions on entity selections and on entity detail

Hello,

 

I have a question related to on how actions interact on a single or multiple entities.

 

1) I currently have customized actions that are only shown in the detailed view of an entity: These actions work on a single entity instance. I wander how and if I could see and invoke the same action from the filterable bean collection module (= the entity search panel). I then need to convert my customized action, a WrappingAction, into a ModuleObjectFrontAction, don’t I? I also wander whether my customized action will then be applicable to a selection of entity instances whereas until now I only can invoke my customized action on a single entity instance.

 

2) The other way around: We have by default several actions in the entity search panel, amongst others the standard save action and the standard contents reload action. For both mentioned actions, it is only logical to show them also in the detailed view action, isn’it? I thus would like to understand what is the best way to make both actions available in the entity detailed view.

 

Your thoughts are welcome, as well as directions on how to proceed.

Marc

AttachmentSize
SubmitStateAction.txt2.03 KB
Edited by Marc on 01/28/2010 - 18:04
vvandens
Offline
Joined: 05/29/2008
[help] actions on entity selections and on entity detail

Hi Marc,

There has been some work recently to simplify action coding and ease what you are trying to achieve. Take a look at all the helper methods that are defined in org.jspresso.framework.application.action.AbstractActionContextAware. Since all actions inherit this base helper class, you can use them in your actions implementation.

The one(s) you are looking for is either :

  • Object getSelectedModel(Map<String, Object> context) : it will return either the model behind a single model view (the detail view for instance) or the leading selected element in a collection view (the result list for instance).
  • List<?> getSelectedModels(Map<String, Object> context) : it will return either the model behind a single model view (the detail view for instance) or all the selected elements in a colection view (the result list for instance).

Using these methods allows you to implement versatile actions that can be assigned both to collection views and single model views.

 

BTW, there has been some naming refactoring as described in the trunk release notes (look for "WrappingAction"). The whole action hierarchy has been refactored and is now much more consistent. As a consequence, WrappingAction has been deprecated and replaced by FrontendAction.

 

Best,

Vincent

Marc
Offline
Joined: 07/08/2009
Lost in upgrading my custom code

Hello again Vincent & co,

I had a customised transactional action that worked before and that I try to reform according to the newly refactoring of actions. But I am a bit lost. I got the following error:

"java.lang.NullPointerException
        at org.jspresso.framework.application.backend.action.persistence.hiberna
te.SaveAction$1.doInTransaction(SaveAction.java:50)"

I include here my Java code as file attachment, you can see in the comments what I changed since the previous version. The method "execute" executes partially, i.e. the destinationState is quite set, but then I get a pop-up window showing "error". So I think the problems arises in the last statement (return super.execute(actionHandler, context);)

Can you give an indication? I still need to writte the tranactional annotation as before I guess?

Thanks,

Marc

vvandens
Offline
Joined: 05/29/2008
NPE in SaveAction

Hi Marc,

The standard "SaveAction" that is wired as nextAction after your custom SubmitStateAction expects a not-null collection of entities to save to the datastore. This collection should be passed as the action parameter, i.e. the commented line in your code :

setActionParameter(Collections.singletonList(copiedEntity), context);

I've just improved the SaveAction so that it performs now the missing not-null check and treats the null collection as if there was nothing to do.

 

BTW, why did you comment those 4 lines of code ? They seem valid to me, unless I'm missing something. Beware that your current SubmitStateAction implementation won't register anything to be saved in the next SaveAction...

 

HTH,

Vincent

Marc
Offline
Joined: 07/08/2009
problem with actionabilitygate in frontend.xml

Vincent,

So far so good.

I encounter now a new problem.

I want now to enable my customised action (the same SubmitStateAction) that works in the detailed entity view, on the filterable bean collection module. It works as long as I do not use actionabilityGates. But when I specify an actionabilityGate, then the system says that he can not find the related property. I just copied the entire FrontendAction bean from view.xml into frontend.xml.

Any idea?

(PS: I also tried to give my FrontendAction bean in view.xml an id, and to refer it from within frontend.xml, but then the system says that it can not find that bean.)

Thanks,
Marc

vvandens
Offline
Joined: 05/29/2008
problem with actionabilitygate in frontend.xml

 

Hi Marc,

As of now, actionability gates can't take their model from the selected row in a collection view (their model is taken from the owner of the collection, i.e. the master entity/module object). This means that they are not designed to be assigned to actions that should be enabled/disabled based on the selected object(s) in a table for instance.

 

This may change in the future but their are several design questions to solve, like :

  • Give the ability to configure the action (or each individual actionability gate) so that their gates' model are taken from :
    • the master (owner of the collection property)
    • the selected detail(s)
  • Cleanly handle multi-selection on collection views, i.e. the action must be enabled if and anly if :
    • all "master-based" gates are open, and
    • all "detail-based" gates for all selected details are open

 

HTH,

Vincent

Marc
Offline
Joined: 07/08/2009
Delete action doesn't work in the entity detail view

Vincent,

I understand the challenges you mention above.

Another remark:

I also tried to enable the detailed entity view with the save and with the delete operation. This works very well for the save. The delete operation on the contrary gives the error:

"org.jspresso.framework.binding.model.ModelRefPropertyConnector cannot be cast to org.jspresso.framework.binding.ICollectionConnector"

In this case I already see another challenge related to screen flow: after deleting an entity while being in the entity detail view, we should automatically return to the module pane I would suggest.

I do not not need this feature immediately. I just wanted to report it.

Regards,

Marc

vvandens
Offline
Joined: 05/29/2008
problem with actionabilitygate in frontend.xml

Hi Marc,

The last published SNAPSHOT contains the improvement mentionned above :

  • Model based action gates can now be configured to work on the collection selected detail(s) (whenever they are attached to an action registered on a collection view) instead of the owning master. Basically, all you have to do is to configure the gates that are to be applied to the selected details with :
    <bean class="org.jspresso.framework.binding.model.BooleanPropertyModelGate">
    <property name="accessorFactory" ref="accessorFactory" />
    <property name="booleanPropertyName" value="myDetailProperty" />
    <property name="openOnTrue" value="true" />
    <property name="collectionBased" value="true"/>
    </bean>
  • Actions themselves can now be configured to be enabled only when there is at least 1 selected detail (whenever they are attached to an action registered on a collection view); this has been applied to standard framework actions :
    <bean class="mypackage.MyAction">
    ...
    ...
    <property name="collectionBased" value="true"/>
    </bean>

 

HTH,

Vincent