Package net.sourceforge.stripes.action

Examples of net.sourceforge.stripes.action.ActionBean


        String event = abc == null ? null : abc.getEventName();
        Resolution resolution = null;

    // Run @Before methods, as long as there's a bean to run them on
    if (context.getActionBean() != null) {
            ActionBean bean = context.getActionBean();
            FilterMethods filterMethods = getFilterMethods(bean.getClass());
      List<Method> beforeMethods = filterMethods.getBeforeMethods(stage);

            for (Method method : beforeMethods) {
                String[] on = method.getAnnotation(Before.class).on();
                if (event == null || CollectionUtil.applies(on, event)) {
                    resolution = invoke(bean, method, stage, Before.class);
                    if (resolution != null) {
                        return resolution;
                    }
                }
            }
        }

        // Continue on and execute other filters and the lifecycle code
        resolution = context.proceed();

        // Run After filter methods (if any)
        if (context.getActionBean() != null) {
            ActionBean bean = context.getActionBean();
            FilterMethods filterMethods = getFilterMethods(bean.getClass());
            List<Method> afterMethods = filterMethods.getAfterMethods(stage);

            // Re-get the event name in case we're executing after handler resolution
            // in which case the name will have been null before, and non-null now
            event = abc == null ? null : abc.getEventName();
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

     * Builds a string that contains field metadata in a JavaScript object.
     *
     * @return JavaScript object containing field metadata
     */
    private String getMetadata() {
        ActionBean bean = null;

        String action = getAction();

        FormTag form = getForm();

        if (form != null) {
            if (action != null)
                log.warn("Parameters action and/or beanclass specified but field-metadata tag is inside of a Stripes form tag. The bean will be pulled from the form tag.");
           
            action = form.getAction();
        }

        if (form != null)
            bean = form.getActionBean();

        Class<? extends ActionBean> beanClass = null;

        if (bean != null)
            beanClass = bean.getClass();
        else if (action != null) {
            beanClass = StripesFilter.getConfiguration().getActionResolver().getActionBeanType(action);
            if (beanClass != null) {
                try {
                    bean = StripesFilter.getConfiguration().getObjectFactory().newInstance(beanClass);
View Full Code Here

                                    String urlBinding) throws StripesServletException {
        try {
            return super.getActionBean(context, urlBinding);
        }
        catch (StripesServletException sse) {
            ActionBean bean = handleActionBeanNotFound(context, urlBinding);
            if (bean != null) {
                setActionBeanContext(bean, context);
                assertGetContextWorks(bean);
                return bean;
            }
View Full Code Here

     * @param urlBinding the urlBinding determined for the current request
     * @return an ActionBean that will render a view for the user, or null
     * @since Stripes 1.3
     */
    protected ActionBean handleActionBeanNotFound(ActionBeanContext context, String urlBinding) {
        ActionBean bean = null;
        Resolution view = findView(urlBinding);

        if (view != null) {
            log.debug("Could not find an ActionBean bound to '", urlBinding, "', but found a view ",
                      "at '", view, "'. Forwarding the user there instead.");
View Full Code Here

    /** Null values are not allowed by {@link ConcurrentHashMap} so use this reference instead. */
    private static final HttpCache NULL_CACHE = CacheKey.class.getAnnotation(HttpCache.class);

    public Resolution intercept(ExecutionContext ctx) throws Exception {
        final ActionBean actionBean = ctx.getActionBean();
        final Method handler = ctx.getHandler();
        if (actionBean != null && handler != null) {
            final Class<? extends ActionBean> beanClass = actionBean.getClass();
            // if caching is disabled, then set the appropriate response headers
            logger.debug("Looking for ", HttpCache.class.getSimpleName(), " on ",
                    beanClass.getName(), ".", handler.getName(), "()");
            final HttpCache annotation = getAnnotation(handler, beanClass);
            if (annotation != null) {
View Full Code Here

     * @return ActionBean the ActionBean bound to the form if there is one
     */
    protected ActionBean getActionBean() {
    String binding = getActionBeanUrlBinding();
    HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
    ActionBean bean = (ActionBean) request.getAttribute(binding);
    if (bean == null) {
      HttpSession session = request.getSession(false);
      if (session != null)
        bean = (ActionBean) session.getAttribute(binding);
    }
View Full Code Here

     * Returns true if the ActionBean this form posts to represents a Wizard action bean and
     * false in all other situations.  If the form cannot determine the ActionBean being posted
     * to for any reason it will return false.
     */
    protected boolean isWizard() {
        ActionBean bean = getActionBean();
        Class<? extends ActionBean> clazz = null;
        if (bean == null) {
            clazz = getActionBeanClass();

            if (clazz == null) {
                log.error("Could not locate an ActionBean that was bound to the URL [",
                          this.actionWithoutContext, "]. Without an ActionBean class Stripes ",
                          "cannot determine whether the ActionBean is a wizard or not. ",
                          "As a result wizard behaviour will be disabled.");
                return false;
            }
        }
        else {
            clazz = bean.getClass();
        }

        return clazz.getAnnotation(Wizard.class) != null;
    }
View Full Code Here

     * @param tag the input tag being registered with the form
     */
    protected void setFocusOnFieldIfRequired(InputTagSupport tag) {
        // Decide whether or not this field should be focused
        if (this.focus != null && !this.focusSet) {
            ActionBean bean = getActionBean();
            ValidationErrors errors = bean == null ? null : bean.getContext().getValidationErrors();

            // If there are validation errors, select the first field in error
            if (errors != null && errors.hasFieldErrors()) {
                List<ValidationError> fieldErrors = errors.get(tag.getName());
                if (fieldErrors != null && fieldErrors.size() > 0) {
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);

                // Prefer the context from the resolved bean if it differs from the ExecutionContext
                if (context != bean.getContext()) {
                    ActionBeanContext other = bean.getContext();
                    other.setEventName(context.getEventName());
                    other.setRequest(context.getRequest());
                    other.setResponse(context.getResponse());

                    context = other;
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.