Package net.sourceforge.stripes.action

Examples of net.sourceforge.stripes.action.ActionBean


     *         EVAL_BODY_TAG if there are errors to display
     */
    @Override
    public int doStartTag() throws JspException {
        HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
        ActionBean mainBean = (ActionBean) request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
        FormTag formTag = getParentTag(FormTag.class);
        ValidationErrors errors = null;

        // If we are supplied with an 'action' attribute then display the errors
        // only if that action matches the 'action' of the current action bean
        if (getAction() != null) {
            if (mainBean != null) {
                String mainAction = StripesFilter.getConfiguration()
                        .getActionResolver().getUrlBinding(mainBean.getClass());

                if (getAction().equals(mainAction)) {
                    errors = mainBean.getContext().getValidationErrors();
                }
            }
        }
        // Else we don't have an 'action' attribute, so see if we are nested in
        // a form tag
        else if (formTag != null) {
            ActionBean formBean = formTag.getActionBean();
            if (formBean != null) {
                errors = formBean.getContext().getValidationErrors();
            }

        }
        // Else if no name was set, and we're not in a action tag, we're global and ok to display
        else if (mainBean != null) {
View Full Code Here


     *
     * @param tag the tag whose values to look for
     * @return an Object, possibly null, representing the tag's value
     */
    protected Object getValueFromActionBean(InputTagSupport tag) throws StripesJspException {
        ActionBean actionBean = tag.getParentFormTag().getActionBean();
        Object value = null;

        if (actionBean != null) {
            try {
                value = BeanUtil.getPropertyValue(tag.getName(), actionBean);
View Full Code Here

     * @return boolean true if the form is in error, false otherwise
     */
    protected boolean isFormInError(InputTagSupport tag) throws StripesJspException {
        boolean inError = false;

        ActionBean actionBean = tag.getParentFormTag().getActionBean();
        if (actionBean != null) {
            ValidationErrors errors = actionBean.getContext().getValidationErrors();
            inError = (errors != null && errors.size() > 0);
        }

        return inError;
    }
View Full Code Here

    /**
     * Gets the (potentially empty) set of Validation Errors that were produced by the request.
     */
    public ValidationErrors getValidationErrors() {
        ActionBean bean = (ActionBean) this.request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
        return bean.getContext().getValidationErrors();
    }
View Full Code Here

     * @throws JspException if the ActionBean could not be instantiate and executed
     */
    @Override
    public int doStartTag() throws JspException {
        // Check to see if the action bean already exists
        ActionBean actionBean = (ActionBean) getPageContext().findAttribute(binding);
        boolean beanNotPresent = actionBean == null;

        try {
            final Configuration config = StripesFilter.getConfiguration();
            final ActionResolver resolver = StripesFilter.getConfiguration().getActionResolver();
            final HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
            final HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();
            Resolution resolution = null;
            ExecutionContext ctx = new ExecutionContext();

            // Lookup the ActionBean if we don't already have it
            if (beanNotPresent) {
                ActionBeanContext tempContext =
                        config.getActionBeanContextFactory().getContextInstance(request, response);
                tempContext.setServletContext(getPageContext().getServletContext());
                ctx.setLifecycleStage(LifecycleStage.ActionBeanResolution);
                ctx.setActionBeanContext(tempContext);

                // Run action bean resolution
                ctx.setInterceptors(config.getInterceptors(LifecycleStage.ActionBeanResolution));
                resolution = ctx.wrap( new Interceptor() {
                    public Resolution intercept(ExecutionContext ec) throws Exception {
                        ActionBean bean = resolver.getActionBean(ec.getActionBeanContext(), binding);
                        ec.setActionBean(bean);
                        return null;
                    }
                });
            }
View Full Code Here

     * @return the name of the form to be used for this request
     */
    public ActionBean getActionBean(ActionBeanContext context) throws StripesServletException {
        HttpServletRequest request = context.getRequest();
        String path = HttpUtil.getRequestedPath(request);
        ActionBean bean = getActionBean(context, path);
        request.setAttribute(RESOLVED_ACTION, getUrlBindingFromPath(path));
        return bean;
    }
View Full Code Here

     * @return a Class<ActionBean> for the ActionBean requested
     * @throws StripesServletException if the UrlBinding does not match an ActionBean binding
     */
    public ActionBean getActionBean(ActionBeanContext context, String path) throws StripesServletException {
        Class<? extends ActionBean> beanClass = getActionBeanType(path);
        ActionBean bean;

        if (beanClass == null) {
            throw new ActionBeanNotFoundException(
                    path, UrlBindingFactory.getInstance().getPathMap());
        }
View Full Code Here

            return super.getValue(tag);
        }
        else {
            // Try getting from the ActionBean.  If the bean is present and the property
            // is defined, then the value from the bean takes precedence even if it's null
            ActionBean bean = tag.getActionBean();
            Object value = null;
            boolean kaboom = false;
            if (bean != null) {
                try {
                    value = BeanUtil.getPropertyValue(tag.getName(), bean);
View Full Code Here

        excludes.add( StripesConstants.URL_KEY_SOURCE_PAGE );
        excludes.add( StripesConstants.URL_KEY_FIELDS_PRESENT );
        excludes.add( StripesConstants.URL_KEY_EVENT_NAME );

        // Use the submitted action bean to eliminate any event related parameters
        ActionBean submittedActionBean = (ActionBean)
                getPageContext().getRequest().getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);

        if (submittedActionBean != null) {
            String eventName = submittedActionBean.getContext().getEventName();
            if (eventName != null) {
                excludes.add(eventName);
                excludes.add(eventName + ".x");
                excludes.add(eventName + ".y");
            }
        }

        // Now get the action bean on this form
        ActionBean actionBean = form.getActionBean();

        // If current form only is not specified, go ahead, otherwise check that
        // the current form had an ActionBean attached - which indicates that the
        // last submit was to the same form/action as this form
        if (!isCurrentFormOnly() || actionBean != null) {
View Full Code Here

        ctx.setInterceptors(config.getInterceptors(LifecycleStage.ActionBeanResolution));
        return  ctx.wrap( new Interceptor() {
            public Resolution intercept(ExecutionContext ctx) throws Exception {
                // Look up the ActionBean and set it on the context
                ActionBeanContext context = ctx.getActionBeanContext();
                ActionBean bean = StripesFilter.getConfiguration().getActionResolver().getActionBean(context);
                ctx.setActionBean(bean);

                // Then register it in the Request as THE ActionBean for this request
                HttpServletRequest request = context.getRequest();
                request.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN, bean);
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.action.ActionBean

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.