Package net.sourceforge.stripes.action

Examples of net.sourceforge.stripes.action.ActionBean


     * @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

     */
    @Test(groups="fast")
    public void testValidateRequiredAndIgnored() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.execute("validateRequiredAndIgnored");
        ActionBean actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.getContext().getValidationErrors().size(), 0);
    }
View Full Code Here

     */
    @Test(groups="fast")
    public void testValidatePublicField() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.execute("validatePublicField");
        ActionBean actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.getContext().getValidationErrors().size(), 1);
    }
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

  public int doEndTag() throws JspException {
        // Get the current form.
        FormTag form = getParentTag(FormTag.class);

        // 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

        excludes.add(StripesConstants.URL_KEY_EVENT_NAME);
        excludes.add(StripesConstants.URL_KEY_FLASH_SCOPE_ID);

        // Use the submitted action bean to eliminate any event related parameters
        ServletRequest request = getPageContext().getRequest();
        ActionBean submittedActionBean = (ActionBean) request
                .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");
            }
View Full Code Here

        if (path == null)
            throw exception;

        final StripesRequestWrapper wrapper;
        final ActionBeanContext context;
        final ActionBean actionBean;
        try {
            // Create a new request wrapper, avoiding the pitfalls of multipart
            wrapper = new StripesRequestWrapper(request) {
                @Override
                protected void constructMultipartWrapper(HttpServletRequest request)
                        throws StripesServletException {
                    setLocale(configuration.getLocalePicker().pickLocale(request));
                }
            };

            // Create the ActionBean and ActionBeanContext
            context = configuration.getActionBeanContextFactory().getContextInstance(wrapper,
                    response);
            actionBean = configuration.getActionResolver().getActionBean(context);
            wrapper.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN, actionBean);
        }
        catch (ServletException e) {
            log.error(e);
            throw exception;
        }

        // Try to guess the field name by finding exactly one FileBean field
        String fieldName = null;
        try {
            PropertyDescriptor[] pds = ReflectUtil.getPropertyDescriptors(actionBean.getClass());
            for (PropertyDescriptor pd : pds) {
                if (FileBean.class.isAssignableFrom(pd.getPropertyType())) {
                    if (fieldName == null) {
                        // First FileBean field found so set the field name
                        fieldName = pd.getName();
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.