details: /erp/devel/pi/rev/4503b69249d5
changeset: 9803:4503b69249d5
user: Martin Taal <martin.taal <at> openbravo.com>
date: Fri Jan 14 07:21:38 2011 +0100
summary: Direct linking from empty field now opens grid correctly
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
| 41 +++++++--
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
| 2 +-
2 files changed, 33 insertions(+), 10 deletions(-)
diffs (111 lines):
diff -r 938f54df2dca -r 4503b69249d5
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
Fri Jan 14 01:14:36 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
Fri Jan 14 07:21:38 2011 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2009 Openbravo SLU
+ * All portions are Copyright (C) 2010-2011 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -36,7 +36,6 @@
import org.openbravo.client.application.MenuManager.MenuOption;
import org.openbravo.client.kernel.BaseActionHandler;
import org.openbravo.client.kernel.RequestContext;
-import org.openbravo.client.kernel.StaticResourceComponent;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBDal;
import org.openbravo.model.ad.ui.Tab;
@@ -44,10 +43,11 @@
import org.openbravo.service.json.JsonConstants;
/**
- * Is used to compute which records to select in a set of tabs of a certain
window.
+ * Is used to compute which records to select in a set of tabs of a certain
window. It receives the
+ * id and entity of a record and then finds the tab and all the parent tab and
records which need to
+ * be selected. This is then returned to the client to build the ui.
*
* @author mtaal
- * @see StaticResourceComponent
*/
@ApplicationScoped
public class ComputeSelectedRecordActionHandler extends BaseActionHandler {
@@ -83,7 +83,9 @@
if (menuOption.getType() == MenuManager.MenuEntryType.Window) {
if (windowId.equals(menuOption.getMenu().getWindow().getId())) {
// found the window process it
- result = processWindow(menuOption.getMenu().getWindow(),
targetRecordId, targetEntity);
+ final Window menuWindow = OBDal.getInstance().get(Window.class,
+ menuOption.getMenu().getWindow().getId());
+ result = processWindow(menuWindow, targetRecordId, targetEntity);
break;
}
}
@@ -107,8 +109,26 @@
private JSONObject processWindow(Window window, String recordId, String
entityName)
throws Exception {
// create the initial TabInfo
+ final BaseOBObject bob = OBDal.getInstance().get(entityName, recordId);
+
+ // special case, no bob
+ // find the root tab and return only that
+ if (bob == null) {
+ for (Tab tab : window.getADTabList()) {
+ if (tab.isActive() && tab.getModule().isEnabled() && tab.getTabLevel()
== 0) {
+ final TabInfo tabInfo = new TabInfo();
+ tabInfo.setTab(tab);
+ final List<JSONObject> resultList = new ArrayList<JSONObject>();
+ resultList.add(tabInfo.getJSONObject());
+ final JSONObject result = new JSONObject();
+ result.put(RESULT, new JSONArray(resultList));
+ return result;
+ }
+ }
+ throw new OBException("No root tab found in window " + window);
+ }
+
final Tab tab = getTab(window, entityName);
- final BaseOBObject bob = OBDal.getInstance().get(entityName, recordId);
final TabInfo tabInfo = new TabInfo();
tabInfo.setRecord(bob);
tabInfo.setTab(tab);
@@ -144,11 +164,12 @@
private Tab getTab(Window window, String entityName) {
for (Tab tab : window.getADTabList()) {
- if (tab.getTable().getName().equals(entityName)) {
+ if (tab.isActive() && tab.getModule().isEnabled()
+ && tab.getTable().getName().equals(entityName)) {
return tab;
}
}
- return null;
+ throw new OBException("No tab found using entity " + entityName + "
window: " + window);
}
protected JSONObject execute(Map<String, Object> parameters, String data) {
@@ -177,7 +198,9 @@
public JSONObject getJSONObject() throws Exception {
final JSONObject result = new JSONObject();
- result.put(TARGET_RECORD_ID, getRecord().getId());
+ if (getRecord() != null) {
+ result.put(TARGET_RECORD_ID, getRecord().getId());
+ }
result.put(TARGET_TAB_ID, getTab().getId());
return result;
}
diff -r 938f54df2dca -r 4503b69249d5
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
Fri Jan 14 01:14:36 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
Fri Jan 14 07:21:38 2011 +0100
@@ -147,7 +147,7 @@
var standardWindow = this;
var ret = this.Super('draw', arguments);
- if (this.targetRecordId) {
+ if (this.targetTabId) {
OB.RemoteCallManager.call('org.openbravo.client.application.window.ComputeSelectedRecordActionHandler',
null, {
targetEntity: this.targetEntity,
targetRecordId: this.targetRecordId,
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits