Package net.sourceforge.stripes.action

Examples of net.sourceforge.stripes.action.ActionBean


        }
        else {
            try {
                // Collect the things needed to grab a type converter
                String stringKey = evaluation.getNode().getStringValue();
                ActionBean bean = (ActionBean) evaluation.getExpressionEvaluation().getBean();
                Locale locale = bean.getContext().getLocale();
                Collection errors = new ArrayList<ValidationError>();

                TypeConverter tc = StripesFilter.getConfiguration()
                        .getTypeConverterFactory().getTypeConverter(declaredType, locale);
View Full Code Here


        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

                                    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

    private static final Log logger = Log.getInstance(HttpCacheInterceptor.class);

    private Map<CacheKey, HttpCache> cache = new HashMap<CacheKey, HttpCache>(128);

    public Resolution intercept(ExecutionContext ctx) throws Exception {
        final ActionBean actionBean = ctx.getActionBean();
        final Method handler = ctx.getHandler();
        if (ctx.isResolutionFromHandler() && (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(), "()");
            HttpCache annotation = getAnnotation(handler, beanClass);
            if (annotation != null) {
View Full Code Here

    public void put(ActionBean bean) {
        String binding = StripesFilter.getConfiguration()
                                      .getActionResolver().getUrlBinding(bean.getClass());
        super.put(binding, bean);

        ActionBean main = (ActionBean) request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
        if (main != null && main.equals(bean)) {
            super.put(StripesConstants.REQ_ATTR_ACTION_BEAN, bean);
        }
    }
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

     * 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);

            try {
                bean = beanClass.newInstance();
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.