<commit_before>/*
 * @author <a href="<EMAIL>"><NAME></a>
 * @version $Id$
 */

package org.gridlab.gridsphere.tags.portletui;

import org.gridlab.gridsphere.provider.portletui.beans.ActionSubmitBean;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ArrayList;

public class ActionSubmitTag extends ActionTag {

    protected String key = "";

    protected ActionSubmitBean actionSubmitBean = null;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public int doStartTag() throws JspException {
        actionSubmitBean = new ActionSubmitBean();
        if (!beanId.equals("")) {
            actionSubmitBean = (ActionSubmitBean)pageContext.getAttribute(getBeanKey());
        }
        if (actionSubmitBean == null) actionSubmitBean = new ActionSubmitBean();
        paramBeans = new ArrayList();

        actionSubmitBean.setName(createActionURI());
        if (!key.equals("")) {
            actionSubmitBean.setKey(key);
            Locale locale = pageContext.getRequest().getLocale();
            ResourceBundle bundle = ResourceBundle.getBundle("Portlet", locale);
            String localizedText = bundle.getString(actionSubmitBean.getKey());
            if (localizedText != null) {
                value = localizedText;
            }
        }

        if (!beanId.equals("")) {
            this.updateBaseComponentBean(actionSubmitBean);
        } else {
            this.setBaseComponentBean(actionSubmitBean);
        }

        actionSubmitBean.setAction(action);

        Object parentTag = getParent();
        if (parentTag instanceof ContainerTag) {
            ContainerTag containerTag = (ContainerTag)parentTag;
            containerTag.addTagBean(actionSubmitBean);
        } else {
            try {
                JspWriter out = pageContext.getOut();
                out.print(actionSubmitBean.toStartString());
            } catch (Exception e) {
                throw new JspException(e.getMessage());
            }
        }
        return SKIP_BODY;
    }
}<commit_msg>now allows ActionParam tags to be nested inside<commit_after>/*
 * @author <a href="<EMAIL>"><NAME></a>
 * @version $Id$
 */

package org.gridlab.gridsphere.tags.portletui;

import org.gridlab.gridsphere.provider.portletui.beans.ActionSubmitBean;
import org.gridlab.gridsphere.provider.portletui.beans.ActionParamBean;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ArrayList;
import java.util.Iterator;

public class ActionSubmitTag extends ActionTag {

    protected String key = "";

    protected ActionSubmitBean actionSubmitBean = null;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public int doStartTag() throws JspException {
        actionSubmitBean = new ActionSubmitBean();
        if (!beanId.equals("")) {
            actionSubmitBean = (ActionSubmitBean)pageContext.getAttribute(getBeanKey());
        }
        if (actionSubmitBean == null) actionSubmitBean = new ActionSubmitBean();
        paramBeans = new ArrayList();

        actionSubmitBean.setName(createActionURI());

        if (!key.equals("")) {
            actionSubmitBean.setKey(key);
            Locale locale = pageContext.getRequest().getLocale();
            ResourceBundle bundle = ResourceBundle.getBundle("Portlet", locale);
            String localizedText = bundle.getString(actionSubmitBean.getKey());
            if (localizedText != null) {
                value = localizedText;
            }
        }

        if (!beanId.equals("")) {
            this.updateBaseComponentBean(actionSubmitBean);
        } else {
            this.setBaseComponentBean(actionSubmitBean);
        }

        actionSubmitBean.setAction(action);

        Object parentTag = getParent();
        if (parentTag instanceof ContainerTag) {
            ContainerTag containerTag = (ContainerTag)parentTag;
            containerTag.addTagBean(actionSubmitBean);
        } else {
            try {
                JspWriter out = pageContext.getOut();
                out.print(actionSubmitBean.toStartString());
            } catch (Exception e) {
                throw new JspException(e.getMessage());
            }
        }

        return EVAL_BODY_INCLUDE;
    }

    public int doEndTag() throws JspException {

        Iterator it = paramBeans.iterator();
        while (it.hasNext()) {
            ActionParamBean pbean = (ActionParamBean)it.next();
            portletAction.addParameter(pbean.getName(), pbean.getValue());
        }

        String actionURI = createActionURI();

        actionSubmitBean.setName(actionURI);

        actionSubmitBean.setAction(portletAction.toString());

        if ((bodyContent != null) && (value == null)) {
            actionSubmitBean.setValue(bodyContent.getString());
        }

        try {
            JspWriter out = pageContext.getOut();
            out.print(actionSubmitBean.toEndString());
        } catch (Exception e) {
            throw new JspException(e.getMessage());
        }

        return EVAL_PAGE;
    }

}
{'fraction_non_alphanumeric': 0.1069749952998684, 'fraction_numerical': 0.0, 'mean_word_length': 2.432258064516129, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216316', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1384, 'n_words': 278}