e4ds-template-master and multi tenancy

53 views
Skip to first unread message

bo.co...@gmail.com

unread,
Dec 21, 2013, 9:45:23 PM12/21/13
to extdire...@googlegroups.com
Hello Ralph,

 I'm using your template example and added multi tenancy and connection pooling and currently testing it for a new project. But I have an issue that have not been able to solve.

I have a CurrentTenantIdentifierResolver that get's called and the database connection get's assigned from a custom value in the JpaUserDetails that I added. For some tables like the appuser I would like to make a default connection so all clients would use the same connection for a particular table. How would I be able to intercept what item in the menu tree was clicked through extsdirectspring? I would need it to get it in a java web module like AppLocaleResolver because they get run before the CurrentTenantIdentifierResolver and the service is triggered. Right now if I click on Users the CurrentTenantIdentifierResolver  triggers and then the User service.

Any help and example code would be appreciated.

Thanks,

Bo

Ralph Schaer

unread,
Dec 22, 2013, 2:15:50 AM12/22/13
to extdire...@googlegroups.com
Hi

Not sure if I understand the problem correctly. One thing you could do to inform the server side what item the user clicked is by adding an additional server call.

app/controller/Viewport.js
The onSelectionChange method is called when the user clicks a menu item. Instead of opening the view directly the application first calls a server method and if successful opens the view.

onSelectionChange: function(treePanel, selected) {
var me = this;
if (selected && selected.length === 1) {
navigationService.treeItemClicked(selected[0].raw.view, function() {
me.pushHistoryState(selected[0]);
});
}
},


The server method looks something like this and adds the name of the view into the session
@ExtDirectMethod
public void treeItemClicked(HttpSession session, String view) {
System.out.println(view);
session.setAttribute("aKey", view);
}

The AppLocaleResolver class has access to the session and is able to read the value 'aKey'. 
The disadvantage of this solution is that there is a delay between the click on the menu item and the view opening because of the server roundtrip.

Hope this helps. 

Happy Holidays
Ralph


--
You received this message because you are subscribed to the Google Groups "extdirectspring" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extdirectspri...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ralph Schaer

unread,
Dec 22, 2013, 2:23:22 AM12/22/13
to extdire...@googlegroups.com
Just figured out a way that is maybe better. Ext.Ajax.defaultHeaders allows the application to add additional http headers to the extdirect request. This example adds a header with the key 'value' and the view name as the value.

onSelectionChange: function(treePanel, selected) {
if (selected && selected.length === 1) {
Ext.Ajax.defaultHeaders = {
   'view': selected[0].raw.view
   };
this.pushHistoryState(selected[0]);
}
},

and in AppLocalResolver the method request.getHeader returns the value.
 
@Override
public Locale resolveLocale(HttpServletRequest request) {
String view = request.getHeader("view");
...
...
}




bo.co...@gmail.com

unread,
Dec 22, 2013, 9:05:04 AM12/22/13
to extdire...@googlegroups.com
That is exactly what I was looking for. Works great!
Thank you Ralph and have a great holiday season.
Reply all
Reply to author
Forward
0 new messages