diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java b/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java new file mode 100644 index 0000000000..aeaf32a68b --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java @@ -0,0 +1,52 @@ +/****************************************************************************** + * Copyright (C) 2010 Carlos Ruiz * + * Copyright (C) 2009 Quality Systems & Solutions - globalqss * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ + +package org.adempiere.webui; + +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Desktop; +import org.zkoss.zk.ui.Page; +import org.zkoss.zk.ui.sys.IdGenerator; + +public class AdempiereIdGenerator implements IdGenerator { + + @Override + public String nextComponentUuid(Desktop desktop, Component comp) { + String id = (String) comp.getAttribute("zk_component_ID"); + if (id != null && id.length() > 0) + return id; + String prefix = (String) comp.getAttribute("zk_component_prefix"); + if (prefix == null || prefix.length() == 0) + prefix = "zk_comp_"; + int i = Integer.parseInt(desktop.getAttribute("Id_Num").toString()); + i++;// Start from 1 + desktop.setAttribute("Id_Num", String.valueOf(i)); + return prefix + i; + } + + @Override + public String nextDesktopId(Desktop desktop) { + if (desktop.getAttribute("Id_Num") == null) { + String number = "0"; + desktop.setAttribute("Id_Num", number); + } + return null; + } + + @Override + public String nextPageUuid(Page page) { + return null; + } + +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index 32c8dc5edd..a3c7d0bb35 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -92,6 +92,7 @@ public abstract class WEditor implements EventListener, PropertyChangeListener } this.setComponent(comp); + comp.setAttribute("zk_component_prefix", "Field_" + gridField.getColumnName() + "_" + gridField.getAD_Tab_ID() + "_" + gridField.getWindowNo() + "_"); this.gridField = gridField; this.setMandatory(gridField.isMandatory(false)); this.readOnly = gridField.isReadOnly(); diff --git a/zkwebui/WEB-INF/zk.xml b/zkwebui/WEB-INF/zk.xml index 008348167b..04f37cf8a5 100644 --- a/zkwebui/WEB-INF/zk.xml +++ b/zkwebui/WEB-INF/zk.xml @@ -40,6 +40,10 @@ --> + + org.adempiere.webui.AdempiereIdGenerator + +