Package org.ofbiz.base.util.collections

Examples of org.ofbiz.base.util.collections.MapStack


        boolean isEntrySet = false;
        if (!(context instanceof MapStack)) {
            context = MapStack.create(context);
        }
       
        MapStack contextMs = (MapStack) context;
        contextMs.push();

        // create a standAloneStack, basically a "save point" for this SectionsRenderer, and make a new "screens" object just for it so it is isolated and doesn't follow the stack down
        String entryName = this.entryNameExdr.expandString(context);
        String keyName = this.keyNameExdr.expandString(context);
        Object obj = listNameExdr.get(context);
        if (obj == null) {
            Debug.logError("No object found for listName:" + listNameExdr.toString(), module);
            return;
        }
        List theList = null;
        if (obj instanceof Map ) {
            Set entrySet = ((Map)obj).entrySet();  
            Object [] a = entrySet.toArray();
            theList = Arrays.asList(a);
            isEntrySet = true;
        } else if (obj instanceof List ) {
            theList = (List)obj;
        } else {
            Debug.logError("Object not list or map type", module);
            return;
        }
        getListLimits(context, theList);
        int rowCount = 0;
        Iterator iter = theList.iterator();
        int itemIndex = -1;
        while (iter.hasNext()) {
            itemIndex++;
            if (itemIndex >= highIndex) {
                break;
            }
            Object item = iter.next();
            if (itemIndex < lowIndex) {
                continue;
            }
            if (isEntrySet) {
                contextMs.put(entryName, ((Map)item).get("value"));  
                contextMs.put(keyName, ((Map)item).get("key"));  
            } else {
                contextMs.put(entryName, item);
            }
            contextMs.put("itemIndex", new Integer(itemIndex));
           
            rowCount++;
            Iterator sectionIter = this.sectionList.iterator();
            while (sectionIter.hasNext()) {
                ModelScreenWidget.Section section = (ModelScreenWidget.Section)sectionIter.next();
                section.renderWidgetString(writer, contextMs, screenStringRenderer);
            }
        }
        if ((itemIndex + 1) < highIndex) {
            setHighIndex(itemIndex + 1);
        }
        setActualPageSize(highIndex - lowIndex);
        if (paginate) {
            try {
                renderNextPrev(writer, context);  
            } catch(IOException e) {
                Debug.logError(e, module);  
                throw new RuntimeException(e.getMessage());
            }
        }
        contextMs.pop();

    }
View Full Code Here


                Iterator valueIter = values.iterator();
                while (valueIter.hasNext()) {
                    GenericValue value = (GenericValue) valueIter.next();
                    // add key and description with string expansion, ie expanding ${} stuff, passing locale explicitly to expand value string because it won't be found in the Entity
                    MapStack localContext = null;
                    if (context instanceof MapStack) {
                        localContext = ((MapStack) context).standAloneStack();
                    } else {
                        localContext = MapStack.create(context);
                    }
                    localContext.push(value);

                    // expand with the new localContext, which is locale aware
                    String optionDesc = this.description.expandString(localContext, locale);
                   
                    Object keyFieldObject = value.get(this.getKeyFieldName());
View Full Code Here

TOP

Related Classes of org.ofbiz.base.util.collections.MapStack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.