Package com.volantis.mcs.protocols.forms

Examples of com.volantis.mcs.protocols.forms.FormDataManager


        context.setVolantis(volantis);
        context.setRequestURL(new MarinerURL("http://a.url"));

        FormDescriptor fd = new FormDescriptor();
        fd.setName(formName);
        final FormDataManager formDataManager = context.getFormDataManager();
        String formSpecifier = formDataManager.getFormSpecifier(fd);

        context.setPolicyReferenceResolver(referenceResolverMock);

        context.pushDeviceLayoutContext(new DeviceLayoutContext());
        PageGenerationCache pageGenerationCache = new PageGenerationCache();
        pageGenerationCache.createFormFragmentationStates(form.getName());
        context.setPageGenerationCache(pageGenerationCache);
        protocol.setMarinerPageContext(context);
        if(protocol.getPageHead()==null) {
            protocol.initialisePageHead();
        }
        context.setProtocol(protocol);

        TestDeviceLayoutContext dlc = new TestDeviceLayoutContext();
        Pane pane = new Pane(layout);
        FormFragmentInstance ffInstance = new FormFragmentInstance(
                NDimensionalIndex.ZERO_DIMENSIONS) {
            protected boolean isEmptyImpl() {
                return false;
            }

        };
        pane.setName("pane");

        // Activate the device layout.
        RuntimeDeviceLayout runtimeDeviceLayout =
                RuntimeDeviceLayoutTestHelper.activate(layout);

        context.setDeviceLayout(runtimeDeviceLayout);
        context.setDevice(InternalDeviceTestHelper.createTestDevice());
        context.setCurrentPane(pane);
        dlc.setFormatInstance(pane, NDimensionalIndex.ZERO_DIMENSIONS,
                ffInstance);
        dlc.setMarinerPageContext(context);
        dlc.setDeviceLayout(runtimeDeviceLayout);
        //dlc.initialise();
        context.pushDeviceLayoutContext(dlc);
        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        ContextInternals.setEnvironmentContext(requestContext, new TestEnvironmentContext());
        context.pushRequestContext(requestContext);
        ContextInternals.setMarinerPageContext(requestContext, context);

        DOMOutputBuffer dom = new DOMOutputBuffer();
        dom.initialise();
        XFFormAttributes attributes = new XFFormAttributes();
        final Styles styles = StylesBuilder.getInitialValueStyles();
        attributes.setStyles(styles);
        attributes.setFormData(formInstance);
        attributes.setAction(new LiteralLinkAssetReference("testaction"));
        attributes.setMethod("post");
        attributes.setFormSpecifier(formSpecifier);
        attributes.setFormDescriptor(fd);
        FormFragment formFragment = new FormFragment(layout);
        formFragment.setName(fragmentName);
        FormFragmentInstance formFragmentInstance = new FormFragmentInstance(
                NDimensionalIndex.ZERO_DIMENSIONS);
        formFragmentInstance.setFormat(formFragment);
        Link link = new Link(fragmentName, URLConstants.NEXT_FORM_FRAGMENT, styles);
        link.setFormFragment(formFragmentInstance);

        protocol.doFormLink(dom, attributes, link);

        SessionFormData retrievedFormData =
                formDataManager.getSessionFormData(formSpecifier);
        assertEquals("Unexpected FormFragmentData in the SessionContext " +
                fragmentName + " field.", testURL,
                retrievedFormData.getFieldValue(URLConstants.NEXT_FORM_FRAGMENT));
    }
View Full Code Here


    }

    // Javadoc inherited.
    public FormDataManager getFormDataManager() {
        if (formDataManager == null) {
            formDataManager = new FormDataManager();
        }
        return formDataManager;
    }
View Full Code Here

     * @return String form specifier
     */
    protected String getFormSpecifier(XFFormAttributes attributes) {

        // Get the form data manager.
        FormDataManager manager = context.getFormDataManager();

        String formSpecifier = attributes.getFormSpecifier();
        FormDescriptor formDescriptor = attributes.getFormDescriptor();

        if (formSpecifier == null) {
            // This will add the form descriptor to the cache and create the a
            // new form specifier for it if none exists, or return an existing
            // specifier if the descriptor is already in the cache.
            formSpecifier = manager.getFormSpecifier(formDescriptor);
            attributes.setFormSpecifier(formSpecifier);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Form specifier for " + formDescriptor
View Full Code Here

            logger.debug("Setting vaction attribute for form specifier: "
                         + formSpecifier + " to :" + transformedLink);
        }
       
        // Set the field value in the session
        FormDataManager dataManager = context.getFormDataManager();
        if (dataManager != null) {
            SessionFormData sessionData = dataManager.getSessionFormData(formSpecifier);
            sessionData.setFieldValue(URLConstants.ACTION_FORM_FRAGMENT,
                    transformedLink);
        }
    }
View Full Code Here

            final XFFormAttributes xfFormAttributes =
                    model.getXFFormAttributes();
            final EmulatedXFormDescriptor fd = model.getXFormDescriptor();

            MarinerPageContext pageContext = protocol.getMarinerPageContext();
            FormDataManager formDataManager = pageContext.getFormDataManager();

            // Store the form data in the XFFormAttributes.
            xfFormAttributes.setFormData(model.getFormData());

            // Get the form data from the session context. The act of
            // retrieving it causes it to be created if it isn't already there.
            SessionFormData formData = formDataManager.getSessionFormData(fd);
            // The fd in the session is built up over requests for subsequent
            // fragments, so add the fields found in this request to it.
            formData.addFieldDescriptors(fd.getFields());

            // Set the form specifier (which identifies the form in the
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.forms.FormDataManager

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.