edit button in master-detail action map and data auto loading

9 posts / 0 new
Last post
axidavid
Offline
Joined: 07/21/2010
edit button in master-detail action map and data auto loading

hi

 

i'd like to have an edit button in a detail grid instead of the tabular entry

i don't know how to do it in SJS(i've seen some threads about that but not in groovy)

(i have read the view.groovy from the hr app , but i doesn't work)

 

also i'd like for small table (with a few rows) to have the grid loaded when first displayed

i've seen elsewhere i need a java class but what do i need to describe in groovy ??

 

more generaly , the groovy dsl is very nice , but it's hard to visualize all the options available when you describe a view, a module or an actionMap

 

sorry for my noob questions

 

thanks

vvandens
Offline
Joined: 05/29/2008
edit button in master-detail action map and data auto loading

David,

I can see at least 2 solutions to achieve what you want.

The first one consists in making the selected record the model of a bean sub-module. This can be easily done using the built-in addAsChildModuleFrontAction as described in this post. Here is the SJS version adapted (and tested) in the HR sample application (installed on the department teams table to edit a team as a sub-module in the workspace tree) :

form ('Team.pane') // The view we want to use for the team edition  

action('yourCustomAction', parent:'addAsChildModuleFrontAction') { //define a top-level, referenceable action
wrapped(class:'org.jspresso.framework.application.backend.action.module.AddBeanAsSubModuleAction',
custom:['childModuleProjectedViewDescriptor_ref':'Team.pane']) // and customize it to display the view defined above
}

table('Department-teams.table', // we install it on the department teams table view
columns:['ouId','name','manager'],
readOnly:true, // we make the table read-only so that we can install a row double-click action
  rowAction:'yourCustomAction') { // We install our action as the row double-click action
actionMap (parents:['masterDetail']) { // but we can also complement the standard master-detail action map
actionList('View') { // by adding a new action list (i.e. toolbar section)
action ref:'yourCustomAction'
}
}
}

The second option is to use a dialog poping-up for editing the selected team. This one needs a few lines of code using the 3.5.0 release, but I've just deployed a new snapshot that makes the stuff really straightforward. So if you change your project root pom.xml to bind to 3.5-SNAPSHOT instead of 3.5.0, you will be able to replace the action in the snippet above by the following lines :

action'yourCustomAction',
parent:'editSelectedComponentAction',
custom:['viewDescriptor_ref':'Team.pane']

Could hardly be shorter, right ? BTW, one difference with the previous action, is that this one uses Jspresso "Unit of Work" mechnism that allows to work transactionally in memory, i.e. the dialog actually displays a deep copy of the selected team so that clicking "Ok" actually commits the modification in the session entity and clicking "Cancel" rolls back the modifications.

 

As for your second point, you can easily pre-load a filter module by registering a startup action (that gets trigerred when the module is first displayed), e.g. (taken from HRsample snapshot) :

action 'filterModuleStartup',
class:'org.jspresso.framework.application.frontend.action.FrontendAction',
wrapped:'initModuleFilterAction',
next:'queryModuleFilterAction'

workspace('organization.workspace',
icon:'structure-48x48.png',
grantedRoles:['administrator','organization-manager']) {
filterModule('companies.module',
icon:'company-48x48.png',
component:'Company',
detailView:'Company.module.view',
startup:'filterModuleStartup')
}

 

more generaly , the groovy dsl is very nice,

Thanks!

but it's hard to visualize all the options available when you describe a view, a module or an actionMap

 We are working hard on doc, but the key will surely be SJSPlug (and contextual doc).

 

Best,

Vincent

axidavid
Offline
Joined: 07/21/2010
hi Vincentthanks for your
hi Vincent

thanks for your quick answers

for the first point : i've errors in my view.groovy in mvn package

RAE-Reference already exists : <Interlocuteur.detail.pane>('view

RAE-Reference already exists : <AdresseClient.detail.pane>('view

 

here is a snippet of my view.groovy file :

form

  'AdresseClient.detail.pane',

labelsPosition:'ASIDE',

columnCount:2,

 

fields:['nom','contact.adresse','contact.ville', 'contact.codePostal','contact.telephone','contact.fax','contact.email'],

widths:[name:2]

 form 'Interlocuteur.detail.pane',

 

labelsPosition:'ASIDE',

 

columnCount:2,

 

fields:['prenom','nom','telephone', 'portable','email', 'fonction'],

 

widths:[email:2]

 action'editDetailAdresseAction',

parent:'editSelectedComponentAction' 

custom:['viewDescriptor_ref':'AdresseClient.detail.pane']

 action'editDetailInterlocuteurAction',

 

parent:'editSelectedComponentAction'

 

custom:['viewDescriptor_ref':'Interlocuteur.detail.pane']

 

 

 

 

table

 

 

('Client-interlocuteurs.table'

,

 

 

readOnly:true

,

 

 

rowAction:'editDetailInterlocuteurAction'

) {

 

 

actionMap (parents:['masterDetail']) {

// but we can also complement the standard master-detail action map

 

 

 

actionList('View') {

// by adding a new action list (i.e. toolbar section)

 

 

 

action ref:'editDetailInterlocuteurAction'

} }}

 

 

 

table('Client-adresses.table'

,

 

 

readOnly:true

,

 

 

rowAction:'editDetailAdresseAction'

) {

 

 

actionMap (parents:['masterDetail']) {

// but we can also complement the standard master-detail action map

 

 

 

actionList('View') {

// by adding a new action list (i.e. toolbar section)

 

 

 

action ref:'editDetailAdresseAction'

} }}

axidavid
Offline
Joined: 07/21/2010
if i remove my

if i remove my Interlocuteur.deail.pane and AdresseClient.detail.pane the mvn package is ok

but i ve got a blank popup with an error message when i click the new button :

Details :
    null

Pile d'appel :
    org.jspresso.framework.application.frontend.action.std.AbstractEditComponentAction.execute(AbstractEditComponentAction.java:78)
    org.jspresso.framework.application.frontend.controller.AbstractFrontendController.executeFrontend(AbstractFrontendController.java:946)
    org.jspresso.framework.application.frontend.controller.AbstractFrontendController.execute(AbstractFrontendController.java:341)
    org.jspresso.framework.application.frontend.controller.swing.DefaultSwingController.execute(DefaultSwingController.java:299)
    org.jspresso.framework.view.swing.SwingActionFactory$ActionAdapter.actionPerformed(SwingActionFactory.java:134)
    javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    org.jvnet.substance.utils.RolloverButtonListener.mouseReleased(RolloverButtonListener.java:109)
    java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    java.awt.Component.processMouseEvent(Unknown Source)
    javax.swing.JComponent.processMouseEvent(Unknown Source)
    java.awt.Component.processEvent(Unknown Source)
    java.awt.Container.processEvent(Unknown Source)
    java.awt.Component.dispatchEventImpl(Unknown Source)
    java.awt.Container.dispatchEventImpl(Unknown Source)
    java.awt.Component.dispatchEvent(Unknown Source)
    java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    java.awt.Container.dispatchEventImpl(Unknown Source)
    java.awt.Window.dispatchEventImpl(Unknown Source)
    java.awt.Component.dispatchEvent(Unknown Source)
    java.awt.EventQueue.dispatchEvent(Unknown Source)
    org.jspresso.framework.util.swing.WaitCursorEventQueue.dispatchEvent(WaitCursorEventQueue.java:56)
    java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    java.awt.EventDispatchThread.run(Unknown Source)

maxime
Offline
Joined: 06/23/2008
Hi David I will try to help

Hi David

I will try to help you... can you zip and attach your SJS groovy files (or all the "core" directory if you added java files to you Jspresso project) ?

I will come back from holiday on Sunday... I will answer you by Monday evening...

Regards,

Maxime

cvieira
Offline
Joined: 04/24/2009
Hi, i've tried the Vincent

Hi, i've tried the Vincent solution, and it works fine. Althought, when the Team.pane view is showed, we don't have any toolbar (at least with a back button, for exeample). How can this be achieved? The same happens on this quite similar case - http://www.jspresso.org/forum/add-button-open-entity.

Thanks,
Carlos V.

vvandens
Offline
Joined: 05/29/2008
beanModuleActionMap

Hi Carlos,

No view ever comes with any default action map, so you have to assign one to the Team.pane view if you want one. Moreover, you can use the built-in beanModuleActionMap so that you view comes with a set of standard bean module buttons.

 

HTH,

Vincent

cvieira
Offline
Joined: 04/24/2009
Built-In Action Maps

Many Thanks Vincent! It works fine :) Although i think it doesn't work when we apply the action to the add button... the Team view is displayed with no toolbar.

Where can i find a list of built-in actions maps, its descriptions, how to override them or create new ones from scratch? This documentation exists? On reference guide i cannot find the list of these built-in action maps.

Regards,

Carlos V.

vvandens
Offline
Joined: 05/29/2008
Built-In Action Maps

Hi Carlos,

Unfortunately, built-in action maps are not documented. Only built-in actions are.

However, as a rough reference you can search for "Action maps" in this Spring context file.

 

HTH,

Vincent