Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Fri Mar 27 16:59:28 2009 @@ -66,18 +66,18 @@ public class ScreenRenderer { public static final String module = ScreenRenderer.class.getName(); - + protected Appendable writer; protected MapStack<String> context; protected ScreenStringRenderer screenStringRenderer; - + public ScreenRenderer(Appendable writer, MapStack<String> context, ScreenStringRenderer screenStringRenderer) { this.writer = writer; this.context = context; if (this.context == null) this.context = MapStack.create(); this.screenStringRenderer = screenStringRenderer; } - + /** * Renders the named screen using the render environment configured when this ScreenRenderer was created. * @@ -158,7 +158,7 @@ context.put("userLogin", userLogin); context.put("nowTimestamp", UtilDateTime.nowTimestamp()); } - + /** * This method populates the context for this ScreenRenderer based on the HTTP Request and Response objects and the ServletContext. * It leverages various conventions used in other places, namely the ControlServlet and so on, of OFBiz to get the different resources needed. @@ -179,7 +179,7 @@ Map<String, Object> parameterMap = UtilHttp.getCombinedMap(request, attrNamesToSkip); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); - + populateBasicContext(context, screens, parameterMap, (GenericDelegator) request.getAttribute("delegator"), (LocalDispatcher) request.getAttribute("dispatcher"), (Security) request.getAttribute("security"), UtilHttp.getLocale(request), userLogin); @@ -193,7 +193,7 @@ // set up the user's time zone context.put("timeZone", UtilHttp.getTimeZone(request)); - + // ========== setup values that are specific to OFBiz webapps context.put("request", request); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java Fri Mar 27 16:59:28 2009 @@ -38,7 +38,7 @@ import org.ofbiz.widget.text.TextScreenRenderer; public class ScreenTextViewHandler extends AbstractViewHandler { - + public static final String module = ScreenTextViewHandler.class.getName(); protected ServletContext servletContext = null; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java Fri Mar 27 16:59:28 2009 @@ -49,17 +49,17 @@ public class ScreenWidgetViewHandler extends AbstractViewHandler { public static final String module = ScreenWidgetViewHandler.class.getName(); - + protected ServletContext servletContext = null; protected HtmlScreenRenderer htmlScreenRenderer = new HtmlScreenRenderer(); - + /** * @see org.ofbiz.webapp.view.ViewHandler#init(javax.servlet.ServletContext) */ public void init(ServletContext context) throws ViewHandlerException { this.servletContext = context; } - + /** * @see org.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @@ -88,7 +88,7 @@ // to speed up output. writer = new StandardCompress().getWriter(writer, null); } - + ScreenRenderer screens = new ScreenRenderer(writer, null, htmlScreenRenderer); screens.populateContextForRequest(request, response, servletContext); // this is the object used to render forms from their definitions Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java Fri Mar 27 16:59:28 2009 @@ -37,9 +37,9 @@ import org.ofbiz.widget.xml.XmlFormRenderer; public class ScreenXmlViewHandler extends ScreenWidgetViewHandler { - + public static final String module = ScreenXmlViewHandler.class.getName(); - + public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { Writer writer = null; try { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java Fri Mar 27 16:59:28 2009 @@ -58,7 +58,7 @@ public class TextFormRenderer implements FormStringRenderer { public static final String module = TextFormRenderer.class.getName(); - + HttpServletRequest request; HttpServletResponse response; @@ -290,11 +290,11 @@ public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) { // TODO } - + public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) { // TODO } - + public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) { } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Fri Mar 27 16:59:28 2009 @@ -79,13 +79,13 @@ protected String defaultEntityName; protected String defaultPkName; protected boolean forceChildCheck; - + // ===== CONSTRUCTORS ===== /** Default Constructor */ /** XML Constructor */ public ModelTree() {} - + public ModelTree(Element treeElement, GenericDelegator delegator, LocalDispatcher dispatcher) { super(treeElement); this.rootNodeName = treeElement.getAttribute("root-node-name"); @@ -124,13 +124,13 @@ nodeList.add(node); nodeMap.put(nodeName,node); } - + if (nodeList.size() == 0) { throw new IllegalArgumentException("No node elements found for the tree definition with name: " + this.name); } } - + public void setDefaultEntityName(String name) { String nm = name; if (UtilValidate.isEmpty(nm)) { @@ -143,15 +143,15 @@ this.defaultPkName = modelField.getName(); } } - + public String getDefaultEntityName() { return this.defaultEntityName; } - + public String getDefaultPkName() { return this.defaultPkName; } - + public String getRootNodeName() { return rootNodeName; } @@ -159,15 +159,15 @@ public String getWrapStyle(Map<String, Object> context) { return this.defaultWrapStyleExdr.expandString(context); } - + public int getOpenDepth() { return openDepth; } - + public int getPostTrailOpenDepth() { return postTrailOpenDepth; } - + public String getExpandCollapseRequest(Map<String, Object> context) { String expColReq = this.expandCollapseRequestExdr.expandString(context); if (UtilValidate.isEmpty(expColReq)) { @@ -181,19 +181,19 @@ } return expColReq; } - + public String getTrailName(Map<String, Object> context) { return this.trailNameExdr.expandString(context); } - + public String getBoundaryCommentName() { return treeLocation + "#" + name; } - + public void setTreeLocation(String treeLocation) { this.treeLocation = treeLocation; } - + /** * Renders this tree to a String, i.e. in a text format, as defined with the * TreeStringRenderer implementation. @@ -225,7 +225,7 @@ trail = StringUtil.split(treeString, "|"); if (trail == null || trail.size() == 0) throw new RuntimeException("Tree 'trail' value is empty."); - + context.put("rootEntityId", trail.get(0)); context.put(defaultPkName, trail.get(0)); } else { @@ -255,7 +255,7 @@ public String getRenderStyle() { return this.defaultRenderStyle; } - + public static class ModelNode { @@ -291,44 +291,44 @@ setEntityName(nodeElement.getAttribute("entity-name")); if (this.pkName == null || nodeElement.hasAttribute("join-field-name")) this.pkName = nodeElement.getAttribute("join-field-name"); - + Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-one"); if (actionElement != null) { actions.add(new ModelTreeAction.EntityOne(this, actionElement)); } - + actionElement = UtilXml.firstChildElement(nodeElement, "service"); if (actionElement != null) { actions.add(new ModelTreeAction.Service(this, actionElement)); } - + actionElement = UtilXml.firstChildElement(nodeElement, "script"); if (actionElement != null) { actions.add(new ModelTreeAction.Script(this, actionElement)); } - + Element screenElement = UtilXml.firstChildElement(nodeElement, "include-screen"); if (screenElement != null) { this.screenNameExdr = FlexibleStringExpander.getInstance(screenElement.getAttribute("name")); this.screenLocationExdr = FlexibleStringExpander.getInstance(screenElement.getAttribute("location")); this.shareScope = screenElement.getAttribute("share-scope"); } - + Element labelElement = UtilXml.firstChildElement(nodeElement, "label"); if (labelElement != null) { this.label = new Label(labelElement); } - + Element linkElement = UtilXml.firstChildElement(nodeElement, "link"); if (linkElement != null) { this.link = new Link(linkElement); } - + Element imageElement = UtilXml.firstChildElement(nodeElement, "image"); if (imageElement != null) { this.image = new Image(imageElement); } - + /* there are situations in which nothing should be displayed if (screenElement == null && labelElement == null && linkElement == null) { throw new IllegalArgumentException("Neither 'screen' nor 'label' nor 'link' found for the node definition with name: " + this.name); @@ -346,10 +346,10 @@ ModelSubNode subNode = new ModelSubNode(subNodeElementEntry, this); subNodeList.add(subNode); } - - + + } - + public void renderNodeString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer, int depth) throws IOException, GeneralException { @@ -581,37 +581,37 @@ rStyle = modelTree.getRenderStyle(); return rStyle; } - + public boolean isExpandCollapse() { boolean isExpCollapse = false; String rStyle = getRenderStyle(); if (rStyle != null && rStyle.equals("expand-collapse")) isExpCollapse = true; - + return isExpCollapse; } - + public boolean isFollowTrail() { boolean isFollowTrail = false; String rStyle = getRenderStyle(); if (rStyle != null && (rStyle.equals("follow-trail") || rStyle.equals("show-peers") || rStyle.equals("follow-trail"))) { isFollowTrail = true; } - + return isFollowTrail; } - + public boolean isRootNode() { return name.equals(modelTree.getRootNodeName()); } - + public boolean showPeers(int currentDepth, Map<String, Object> context) { int trailSize = 0; List trail = UtilGenerics.checkList(context.get("targetNodeTrail")); int openDepth = modelTree.getOpenDepth(); int postTrailOpenDepth = modelTree.getPostTrailOpenDepth(); if (trail != null) trailSize = trail.size(); - + boolean showPeers = false; String rStyle = getRenderStyle(); if (rStyle == null) { @@ -626,10 +626,10 @@ int depthAfterTrail = currentDepth - trailSize; if (depthAfterTrail >= 0 && depthAfterTrail <= postTrailOpenDepth) showPeers = true; } - + return showPeers; } - + public String getExpandCollapseStyle() { return expandCollapseStyle; } @@ -641,11 +641,11 @@ } return val; } - + public ModelTree getModelTree() { return this.modelTree; } - + public void setEntityName(String name) { this.entityName = name; if (UtilValidate.isNotEmpty(this.entityName)) { @@ -658,7 +658,7 @@ } } } - + public String getEntityName() { if (UtilValidate.isNotEmpty(this.entityName)) { return this.entityName; @@ -666,7 +666,7 @@ return this.modelTree.getDefaultEntityName(); } } - + public String getPkName() { if (UtilValidate.isNotEmpty(this.pkName)) { return this.pkName; @@ -674,85 +674,85 @@ return this.modelTree.getDefaultPkName(); } } - + public void setPkName(String pkName) { this.pkName = pkName; } - + public static class ModelSubNode { - + protected ModelNode rootNode; protected FlexibleStringExpander nodeNameExdr; protected List<ModelTreeAction> actions = FastList.newInstance(); protected ListIterator<? extends Map<String, ? extends Object>> listIterator; - + public ModelSubNode() {} - + public ModelSubNode(Element nodeElement, ModelNode modelNode) { - + this.rootNode = modelNode; this.nodeNameExdr = FlexibleStringExpander.getInstance(nodeElement.getAttribute("node-name")); - + Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-and"); if (actionElement != null) { actions.add(new ModelTreeAction.EntityAnd(this, actionElement)); } - + actionElement = UtilXml.firstChildElement(nodeElement, "service"); if (actionElement != null) { actions.add(new ModelTreeAction.Service(this, actionElement)); } - + actionElement = UtilXml.firstChildElement(nodeElement, "entity-condition"); if (actionElement != null) { actions.add(new ModelTreeAction.EntityCondition(this, actionElement)); } - + actionElement = UtilXml.firstChildElement(nodeElement, "script"); if (actionElement != null) { actions.add(new ModelTreeAction.Script(this, actionElement)); } - + } - + public ModelTree.ModelNode getNode() { return this.rootNode; } - + public String getNodeName(Map<String, Object> context) { return this.nodeNameExdr.expandString(context); } - + public List<ModelTreeAction> getActions() { return actions; } - + public void setListIterator(ListIterator<? extends Map<String, ? extends Object>> iter) { listIterator = iter; } - + public ListIterator<? extends Map<String, ? extends Object>> getListIterator() { return listIterator; } } - + public static class Label { protected FlexibleStringExpander textExdr; - + protected FlexibleStringExpander idExdr; protected FlexibleStringExpander styleExdr; - + public Label(Element labelElement) { - + // put the text attribute first, then the pcdata under the element, if both are there of course String textAttr = UtilFormatOut.checkNull(labelElement.getAttribute("text")); String pcdata = UtilFormatOut.checkNull(UtilXml.elementValue(labelElement)); this.textExdr = FlexibleStringExpander.getInstance(textAttr + pcdata); - + this.idExdr = FlexibleStringExpander.getInstance(labelElement.getAttribute("id")); this.styleExdr = FlexibleStringExpander.getInstance(labelElement.getAttribute("style")); } - + public void renderLabelString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer) { try { treeStringRenderer.renderLabel(writer, context, this); @@ -762,7 +762,7 @@ throw new RuntimeException(errMsg); } } - + public String getText(Map<String, Object> context) { String text = this.textExdr.expandString(context); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -771,17 +771,17 @@ } return text; } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } } - + public static class Link { protected FlexibleStringExpander textExdr; protected FlexibleStringExpander idExdr; @@ -796,7 +796,7 @@ protected boolean fullPath = false; protected boolean secure = false; protected boolean encode = false; - + public Link() { setText(null); setId(null); @@ -813,7 +813,7 @@ } public Link(Element linkElement) { - + setText(linkElement.getAttribute("text")); setId(linkElement.getAttribute("id")); setStyle(linkElement.getAttribute("style")); @@ -830,9 +830,9 @@ if (imageElement != null) { this.image = new Image(imageElement); } - + } - + public void renderLinkString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer) { try { treeStringRenderer.renderLink(writer, context, this); @@ -842,7 +842,7 @@ throw new RuntimeException(errMsg); } } - + public String getText(Map<String, Object> context) { String text = this.textExdr.expandString(context); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -851,15 +851,15 @@ } return text; } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } @@ -871,7 +871,7 @@ } return title; } - + public String getTarget(Map<String, Object> context) { StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); if (simpleEncoder != null) { @@ -880,31 +880,31 @@ return this.targetExdr.expandString(context); } } - + public String getTargetWindow(Map<String, Object> context) { return this.targetWindowExdr.expandString(context); } - + public String getUrlMode() { return this.urlMode; } - + public String getPrefix(Map<String, Object> context) { return this.prefixExdr.expandString(context); } - + public boolean getFullPath() { return this.fullPath; } - + public boolean getSecure() { return this.secure; } - + public boolean getEncode() { return this.encode; } - + public Image getImage() { return this.image; } @@ -964,7 +964,7 @@ public void setImage(Image img) { this.image = img; } - + } public static class Image { @@ -976,7 +976,7 @@ protected FlexibleStringExpander heightExdr; protected FlexibleStringExpander borderExdr; protected String urlMode; - + public Image() { setSrc(null); @@ -989,7 +989,7 @@ } public Image(Element imageElement) { - + setSrc(imageElement.getAttribute("src")); setId(imageElement.getAttribute("id")); setStyle(imageElement.getAttribute("style")); @@ -997,9 +997,9 @@ setHeight(imageElement.getAttribute("height")); setBorder(UtilFormatOut.checkEmpty(imageElement.getAttribute("border"), "0")); setUrlMode(UtilFormatOut.checkEmpty(imageElement.getAttribute("url-mode"), "content")); - + } - + public void renderImageString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer) { try { treeStringRenderer.renderImage(writer, context, this); @@ -1009,15 +1009,15 @@ throw new RuntimeException(errMsg); } } - + public String getSrc(Map<String, Object> context) { return this.srcExdr.expandString(context); } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -1033,11 +1033,11 @@ public String getBorder(Map<String, Object> context) { return this.borderExdr.expandString(context); } - + public String getUrlMode() { return this.urlMode; } - + public void setSrc(String val) { String textAttr = UtilFormatOut.checkNull(val); this.srcExdr = FlexibleStringExpander.getInstance(textAttr); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java Fri Mar 27 16:59:28 2009 @@ -62,20 +62,20 @@ this.modelNode = modelNode; this.modelTree = modelNode.getModelTree(); } - + public ModelTreeAction(ModelTree.ModelNode.ModelSubNode modelSubNode, Element actionElement) { if (Debug.verboseOn()) Debug.logVerbose("Reading Tree action with name: " + actionElement.getNodeName(), module); this.modelSubNode = modelSubNode; this.modelNode = this.modelSubNode.getNode(); this.modelTree = this.modelNode.getModelTree(); } - + public abstract void runAction(Map<String, Object> context); - + /* public static List readSubActions(ModelTree.ModelNode modelNode, Element parentElement) { List actions = new LinkedList(); - + List actionElementList = UtilXml.childElementList(parentElement); Iterator actionElementIter = actionElementList.iterator(); while (actionElementIter.hasNext()) { @@ -96,25 +96,25 @@ throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName()); } } - + return actions; } */ - + public static void runSubActions(List<ModelTreeAction> actions, Map<String, Object> context) { for (ModelTreeAction action: actions) { if (Debug.verboseOn()) Debug.logVerbose("Running tree action " + action.getClass().getName(), module); action.runAction(context); } } - + public static class SetField extends ModelTreeAction { protected FlexibleMapAccessor<Object> field; protected FlexibleMapAccessor<Object> fromField; protected FlexibleStringExpander valueExdr; protected FlexibleStringExpander globalExdr; protected String type; - + public SetField(ModelTree.ModelNode modelNode, Element setElement) { super (modelNode, setElement); this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field")); @@ -126,12 +126,12 @@ throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a tree widget"); } } - + public void runAction(Map<String, Object> context) { String globalStr = this.globalExdr.expandString(context); // default to false boolean global = "true".equals(globalStr); - + Object newValue = null; if (!this.fromField.isEmpty()) { newValue = this.fromField.get(context); @@ -146,17 +146,17 @@ Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } - + } this.field.put(context, newValue); - + if (global) { Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); if (globalCtx != null) { this.field.put(globalCtx, newValue); } } - + // this is a hack for backward compatibility with the JPublish page object Map<String, Object> page = UtilGenerics.checkMap(context.get("page")); if (page != null) { @@ -164,20 +164,20 @@ } } } - + public static class Script extends ModelTreeAction { protected String location; - + public Script(ModelTree.ModelNode modelNode, Element scriptElement) { super (modelNode, scriptElement); this.location = scriptElement.getAttribute("location"); } - + public Script(ModelTree.ModelNode.ModelSubNode modelSubNode, Element scriptElement) { super (modelSubNode, scriptElement); this.location = scriptElement.getAttribute("location"); } - + public void runAction(Map<String, Object> context) { if (location.endsWith(".bsh")) { try { @@ -214,19 +214,19 @@ protected FlexibleStringExpander resultMapValueNameExdr; protected FlexibleStringExpander valueNameExdr; protected Map<FlexibleMapAccessor<Object>, Object> fieldMap; - + public Service(ModelTree.ModelNode modelNode, Element serviceElement) { super (modelNode, serviceElement); initService(serviceElement); } - + public Service(ModelTree.ModelNode.ModelSubNode modelSubNode, Element serviceElement) { super (modelSubNode, serviceElement); initService(serviceElement); } - + public void initService( Element serviceElement ) { - + this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name")); this.resultMapNameAcsr = FlexibleMapAccessor.getInstance(serviceElement.getAttribute("result-map")); if (this.resultMapNameAcsr.isEmpty()) this.resultMapNameAcsr = FlexibleMapAccessor.getInstance(serviceElement.getAttribute("result-map-name")); @@ -240,16 +240,16 @@ if (this.valueNameExdr.isEmpty()) this.valueNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("value-name")); this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement); } - + public void runAction(Map<String, Object> context) { String serviceNameExpanded = this.serviceNameExdr.expandString(context); if (UtilValidate.isEmpty(serviceNameExpanded)) { throw new IllegalArgumentException("Service name was empty, expanded from: " + this.serviceNameExdr.getOriginal()); } - + String autoFieldMapString = this.autoFieldMapExdr.expandString(context); boolean autoFieldMapBool = !"false".equals(autoFieldMapString); - + try { Map<String, Object> serviceContext = null; if (autoFieldMapBool) { @@ -257,13 +257,13 @@ } else { serviceContext = FastMap.newInstance(); } - + if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); } - + Map<String, Object> result = this.modelTree.getDispatcher().runSync(serviceNameExpanded, serviceContext); - + if (!this.resultMapNameAcsr.isEmpty()) { this.resultMapNameAcsr.put(context, result); String queryString = (String)result.get("queryString"); @@ -274,7 +274,7 @@ String queryStringEncoded = queryString.replaceAll("&", "%26"); context.put("queryStringEncoded", queryStringEncoded); } catch (PatternSyntaxException e) { - + } } } else { @@ -284,7 +284,7 @@ //String resultMapListIteratorName = resultMapListIteratorNameExdr.expandString(context); String resultMapValueName = resultMapValueNameExdr.expandString(context); String valueName = valueNameExdr.expandString(context); - + if (this.modelSubNode != null) { //ListIterator iter = null; if (UtilValidate.isNotEmpty(resultMapListName)) { @@ -318,17 +318,17 @@ public static class EntityOne extends ModelTreeAction { protected PrimaryKeyFinder finder; String valueName; - + public EntityOne(ModelTree.ModelNode modelNode, Element entityOneElement) { super (modelNode, entityOneElement); - + this.valueName = UtilFormatOut.checkEmpty(entityOneElement.getAttribute("value"), entityOneElement.getAttribute("value-name")); if (UtilValidate.isEmpty(this.valueName)) this.valueName = null; entityOneElement.setAttribute("value", this.valueName); - + finder = new PrimaryKeyFinder(entityOneElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelTree.getDelegator()); @@ -343,20 +343,20 @@ public static class EntityAnd extends ModelTreeAction { protected ByAndFinder finder; String listName; - + public EntityAnd(ModelTree.ModelNode.ModelSubNode modelSubNode, Element entityAndElement) { super (modelSubNode, entityAndElement); boolean useCache = "true".equalsIgnoreCase(entityAndElement.getAttribute("use-cache")); Document ownerDoc = entityAndElement.getOwnerDocument(); if (!useCache) UtilXml.addChildElement(entityAndElement, "use-iterator", ownerDoc); - + this.listName = UtilFormatOut.checkEmpty(entityAndElement.getAttribute("list"), entityAndElement.getAttribute("list-name")); if (UtilValidate.isEmpty(this.listName)) this.listName = "_LIST_ITERATOR_"; entityAndElement.setAttribute( "list-name", this.listName); - + finder = new ByAndFinder(entityAndElement); } - + public void runAction(Map<String, Object> context) { try { context.put(this.listName, null); @@ -382,20 +382,20 @@ public static class EntityCondition extends ModelTreeAction { ByConditionFinder finder; String listName; - + public EntityCondition(ModelTree.ModelNode.ModelSubNode modelSubNode, Element entityConditionElement) { super (modelSubNode, entityConditionElement); Document ownerDoc = entityConditionElement.getOwnerDocument(); boolean useCache = "true".equalsIgnoreCase(entityConditionElement.getAttribute("use-cache")); if (!useCache) UtilXml.addChildElement(entityConditionElement, "use-iterator", ownerDoc); - + this.listName = UtilFormatOut.checkEmpty(entityConditionElement.getAttribute("list"), entityConditionElement.getAttribute("list-name")); if (UtilValidate.isEmpty(this.listName)) this.listName = "_LIST_ITERATOR_"; entityConditionElement.setAttribute( "list-name", this.listName); finder = new ByConditionFinder(entityConditionElement); } - + public void runAction(Map<String, Object> context) { try { context.put(this.listName, null); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java Fri Mar 27 16:59:28 2009 @@ -65,17 +65,17 @@ } return rootCondition.eval(context); } - + public static abstract class TreeCondition { protected ModelTree modelTree; public TreeCondition(ModelTree modelTree, Element conditionElement) { this.modelTree = modelTree; } - + public abstract boolean eval(Map<String, Object> context); } - + public static List<TreeCondition> readSubConditions(ModelTree modelTree, Element conditionElement) { List<TreeCondition> condList = FastList.newInstance(); for (Element subElement: UtilXml.childElementList(conditionElement)) { @@ -83,7 +83,7 @@ } return condList; } - + public static TreeCondition readCondition(ModelTree modelTree, Element conditionElement) { if (conditionElement == null) { return null; @@ -114,15 +114,15 @@ throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName()); } } - + public static class And extends TreeCondition { protected List<TreeCondition> subConditions; - + public And(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.subConditions = readSubConditions(modelTree, condElement); } - + public boolean eval(Map<String, Object> context) { // return false for the first one in the list that is false, basic and algo for (TreeCondition subCondition: subConditions) { @@ -133,15 +133,15 @@ return true; } } - + public static class Xor extends TreeCondition { protected List<TreeCondition> subConditions; - + public Xor(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.subConditions = readSubConditions(modelTree, condElement); } - + public boolean eval(Map<String, Object> context) { // if more than one is true stop immediately and return false; if all are false return false; if only one is true return true boolean foundOneTrue = false; @@ -158,15 +158,15 @@ return foundOneTrue; } } - + public static class Or extends TreeCondition { protected List<TreeCondition> subConditions; - + public Or(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.subConditions = readSubConditions(modelTree, condElement); } - + public boolean eval(Map<String, Object> context) { // return true for the first one in the list that is true, basic or algo for (TreeCondition subCondition: subConditions) { @@ -177,38 +177,38 @@ return false; } } - + public static class Not extends TreeCondition { protected TreeCondition subCondition; - + public Not(ModelTree modelTree, Element condElement) { super (modelTree, condElement); Element firstChildElement = UtilXml.firstChildElement(condElement); this.subCondition = readCondition(modelTree, firstChildElement); } - + public boolean eval(Map<String, Object> context) { return !this.subCondition.eval(context); } } - + public static class IfHasPermission extends TreeCondition { protected FlexibleStringExpander permissionExdr; protected FlexibleStringExpander actionExdr; - + public IfHasPermission(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.permissionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("permission")); this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("action")); } - + public boolean eval(Map<String, Object> context) { // if no user is logged in, treat as if the user does not have permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (userLogin != null) { String permission = permissionExdr.expandString(context); String action = actionExdr.expandString(context); - + Security security = (Security) context.get("security"); if (action != null && action.length() > 0) { // run hasEntityPermission @@ -230,7 +230,7 @@ protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander methodExdr; protected FlexibleStringExpander classExdr; - + public IfValidateMethod(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); @@ -238,11 +238,11 @@ this.methodExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("method")); this.classExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("class")); } - + public boolean eval(Map<String, Object> context) { String methodName = this.methodExdr.expandString(context); String className = this.classExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); String fieldString = null; if (fieldVal != null) { @@ -285,7 +285,7 @@ return resultBool.booleanValue(); } } - + public static class IfCompare extends TreeCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander valueExdr; @@ -293,25 +293,25 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompare(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.valueExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("value")); - + this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format")); } - + public boolean eval(Map<String, Object> context) { String value = this.valueExdr.expandString(context); String format = this.formatExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); - + // always use an empty string by default if (fieldVal == null) { fieldVal = ""; @@ -330,11 +330,11 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfCompareField extends TreeCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleMapAccessor<Object> toFieldAcsr; @@ -342,26 +342,26 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompareField(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field")); if (this.toFieldAcsr.isEmpty()) this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field-name")); - + this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format")); } - + public boolean eval(Map<String, Object> context) { String format = this.formatExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); Object toFieldVal = this.toFieldAcsr.get(context); - + // always use an empty string by default if (fieldVal == null) { fieldVal = ""; @@ -380,25 +380,25 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfRegexp extends TreeCondition { static PatternMatcher matcher = new Perl5Matcher(); static PatternCompiler compiler = new Perl5Compiler(); protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; - + public IfRegexp(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.exprExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("expr")); } - + public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); String expr = this.exprExdr.expandString(context); @@ -419,20 +419,20 @@ } // always use an empty string by default if (fieldString == null) fieldString = ""; - + return matcher.matches(fieldString, pattern); } } - + public static class IfEmpty extends TreeCondition { protected FlexibleMapAccessor<Object> fieldAcsr; - + public IfEmpty(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); } - + public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); return ObjectType.isEmpty(fieldVal); @@ -440,14 +440,14 @@ } public static class IfEntityPermission extends TreeCondition { protected EntityPermissionChecker permissionChecker; - + public IfEntityPermission(ModelTree modelTree, Element condElement) { super (modelTree, condElement); this.permissionChecker = new EntityPermissionChecker(condElement); } - + public boolean eval(Map<String, Object> context) { - + boolean passed = permissionChecker.runPermissionCheck(context); return passed; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java Fri Mar 27 16:59:28 2009 @@ -44,12 +44,12 @@ * Widget Library - Tree factory class */ public class TreeFactory { - + public static final String module = TreeFactory.class.getName(); public static final UtilCache<String, Map<String, ModelTree>> treeLocationCache = new UtilCache<String, Map<String, ModelTree>>("widget.tree.locationResource", 0, 0, false); public static final UtilCache<String, Map<String, ModelTree>> treeWebappCache = new UtilCache<String, Map<String, ModelTree>>("widget.tree.webappResource", 0, 0, false); - + public static ModelTree getTreeFromLocation(String resourceName, String treeName, GenericDelegator delegator, LocalDispatcher dispatcher) throws IOException, SAXException, ParserConfigurationException { Map<String, ModelTree> modelTreeMap = treeLocationCache.get(resourceName); @@ -61,7 +61,7 @@ if (loader == null) { loader = TreeFactory.class.getClassLoader(); } - + URL treeFileUrl = null; treeFileUrl = FlexibleLocation.resolveLocation(resourceName); //, loader); Document treeFileDoc = UtilXml.readXmlDocument(treeFileUrl, true); @@ -70,20 +70,20 @@ } } } - + ModelTree modelTree = (ModelTree) modelTreeMap.get(treeName); if (modelTree == null) { throw new IllegalArgumentException("Could not find tree with name [" + treeName + "] in class resource [" + resourceName + "]"); } return modelTree; } - + public static ModelTree getTreeFromWebappContext(String resourceName, String treeName, HttpServletRequest request) throws IOException, SAXException, ParserConfigurationException { String webappName = UtilHttp.getApplicationName(request); String cacheKey = webappName + "::" + resourceName; - - + + Map<String, ModelTree> modelTreeMap = treeWebappCache.get(cacheKey); if (modelTreeMap == null) { synchronized (TreeFactory.class) { @@ -92,7 +92,7 @@ ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - + URL treeFileUrl = servletContext.getResource(resourceName); Document treeFileDoc = UtilXml.readXmlDocument(treeFileUrl, true); modelTreeMap = readTreeDocument(treeFileDoc, delegator, dispatcher, cacheKey); @@ -100,14 +100,14 @@ } } } - + ModelTree modelTree = (ModelTree) modelTreeMap.get(treeName); if (modelTree == null) { throw new IllegalArgumentException("Could not find tree with name [" + treeName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]"); } return modelTree; } - + public static Map<String, ModelTree> readTreeDocument(Document treeFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher, String treeLocation) { Map<String, ModelTree> modelTreeMap = new HashMap<String, ModelTree>(); if (treeFileDoc != null) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java Fri Mar 27 16:59:28 2009 @@ -57,7 +57,7 @@ public class XmlFormRenderer implements FormStringRenderer { public static final String module = XmlFormRenderer.class.getName(); - + HttpServletRequest request; HttpServletResponse response; @@ -328,11 +328,11 @@ public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { // TODO } - + public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException { // TODO } - + public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { } } |
Free forum by Nabble | Edit this page |