tf.setAttributeValues (attributeKey, "" + c.getDisplayValue(node));
tf.setAttributeValues (attributeKey, "" + c.getDisplayValue());
    public ActionForward execute(ComponentContext context,                                 ActionMapping mapping,                                 ActionForm form,                                 HttpServletRequest request,                                 HttpServletResponse response)        throws Exception {        HttpSession session = request.getSession();        ServletContext servletContext = session.getServletContext();        Profile profile = (Profile) session.getAttribute(Constants.PROFILE);        ObjectStore os = (ObjectStore) servletContext.getAttribute(Constants.OBJECTSTORE);        ObjectStoreSummary oss = (ObjectStoreSummary) servletContext.                                               getAttribute(Constants.OBJECT_STORE_SUMMARY);        TemplateForm tf = (TemplateForm) form;        TemplateQuery template = null;        String queryName = request.getParameter("name");        String type = request.getParameter("type");        boolean populate = true;                if (queryName == null) {            queryName = request.getParameter("templateName");        }                // look for request attribute "previewTemplate" which is set while building a template        template = (TemplateQuery) request.getAttribute("previewTemplate");                if (context.getAttribute("builder") != null) {            PathQuery query = (PathQuery) session.getAttribute(Constants.QUERY);            PathQuery queryClone = (PathQuery) query.clone();            TemplateBuildState tbs = (TemplateBuildState)                    session.getAttribute(Constants.TEMPLATE_BUILD_STATE);            template = TemplateHelper.buildTemplateQuery(tbs, query);            request.setAttribute("previewTemplate", template);        }                if (queryName == null && template != null) {            queryName = template.getName();        } else {            if (type == null) {                type = TemplateHelper.GLOBAL_TEMPLATE;            }            template = TemplateHelper.findTemplate(session, queryName, type);        }                if (template == null) {            return null;        }                Map displayConstraints = new HashMap();        Map names = new HashMap();        Map constraints = new HashMap();                int j = 0;                // For each node with an editable constraint, create a DisplayConstraint bean        // and the human-readable "name" for each node (Department.company.name -> "Company namae")                for (Iterator i = template.getNodes().iterator(); i.hasNext();) {            PathNode node = (PathNode) i.next();                        for (Iterator ci = template.getConstraints(node).iterator(); ci.hasNext();) {                Constraint c = (Constraint) ci.next();                displayConstraints.put(c, new DisplayConstraint(node, os.getModel(), oss));                                PathNode parent = (PathNode) template.getQuery().getNodes().                    get(node.getPath().substring(0, node.getPath().lastIndexOf(".")));                names.put(c, parent.getType() + " "                          + node.getPath().substring(node.getPath().lastIndexOf(".") + 1));                if (populate) {                    String attributeKey = "" + (j + 1);                    tf.setAttributeValues (attributeKey, "" + c.getDisplayValue(node));                    tf.setAttributeOps(attributeKey, "" + c.getOp().getIndex());                    if (c.getIdentifier() != null) {                        // If special request parameter key is present then we initialise                        // the form bean with the parameter value                        String paramName = c.getIdentifier() + "_value";                        String constraintValue = request.getParameter(paramName);                        if (constraintValue != null) {                            tf.setAttributeValues(attributeKey, constraintValue);                        }                    }                }                                j++;            }                        constraints.put(node, template.getConstraints(node));        }                tf.setTemplateName(queryName);        tf.setTemplateType(type);        request.setAttribute("templateQuery", template);        request.setAttribute("names", names);        request.setAttribute("constraints", constraints);        request.setAttribute("displayConstraints", displayConstraints);        if (profile.getSavedBags().size() > 0) {            request.setAttribute("bagOps", MainHelper.mapOps(BagConstraint.VALID_OPS));        }                return null;    }