public void visit()

in src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java [1098:1187]


        public void visit(Node.SetProperty n) throws JasperException {
            String name = n.getTextAttribute("name");
            String property = n.getTextAttribute("property");
            String param = n.getTextAttribute("param");
            Node.JspAttribute value = n.getValue();

            n.setBeginJavaLine(out.getJavaLine());

            if ("*".equals(property)) {
                out
                        .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspect("
                                + "_jspx_page_context.findAttribute("
                                + "\""
                                + name + "\"), request);");
            } else if (value == null) {
                if (param == null) {
                    param = property; // default to same as property
                }
                out
                        .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
                                + "_jspx_page_context.findAttribute(\""
                                + name
                                + "\"), \""
                                + property
                                + "\", request.getParameter(\""
                                + param
                                + "\"), "
                                + "request, \""
                                + param
                                + "\", false);");
            } else if (value.isExpression()) {
                out
                        .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleSetProperty("
                                + "_jspx_page_context.findAttribute(\""
                                + name
                                + "\"), \"" + property + "\",");
                out.print(attributeValue(value, false, null));
                out.println(");");
            } else if (value.isELInterpreterInput()) {
                // We've got to resolve the very call to the interpreter
                // at runtime since we don't know what type to expect
                // in the general case; we thus can't hard-wire the call
                // into the generated code. (XXX We could, however,
                // optimize the case where the bean is exposed with
                // <jsp:useBean>, much as the code here does for
                // getProperty.)

                // The following holds true for the arguments passed to
                // JspRuntimeLibrary.handleSetPropertyExpression():
                // - 'pageContext' is a VariableResolver.
                // - 'this' (either the generated Servlet or the generated tag
                // handler for Tag files) is a FunctionMapper.
                out
                        .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleSetPropertyExpression("
                                + "_jspx_page_context.findAttribute(\""
                                + name
                                + "\"), \""
                                + property
                                + "\", "
                                + quote(value.getValue())
                                + ", "
                                + "_jspx_page_context, "
                                + value.getEL().getMapName() + ");");
            } else if (value.isNamedAttribute()) {
                // If the value for setProperty was specified via
                // jsp:attribute, first generate code to evaluate
                // that body.
                String valueVarName = generateNamedAttributeValue(value
                        .getNamedAttributeNode());
                out
                        .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
                                + "_jspx_page_context.findAttribute(\""
                                + name
                                + "\"), \""
                                + property
                                + "\", "
                                + valueVarName
                                + ", null, null, false);");
            } else {
                out
                        .printin("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
                                + "_jspx_page_context.findAttribute(\""
                                + name
                                + "\"), \"" + property + "\", ");
                out.print(attributeValue(value, false, null));
                out.println(", null, null, false);");
            }

            n.setEndJavaLine(out.getJavaLine());
        }