Package com.volantis.mcs.protocols.forms

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


            // Update the form parameters. This involves iterating through all the
            // fields removing any protocol specific parameters from the request url
            // and adding them to the pure url. Currently the
            for (int i = 0; i < count; i += 1) {
                FieldDescriptor field = (FieldDescriptor) fields.get(i);
                FieldType type = field.getType();
                FieldHandler handler = type.getFieldHandler(protocol);
                if (logger.isDebugEnabled()) {
                    logger.debug("Updating parameter(s) for " + field);
                }
                handler.updateParameterValue(this, field, pureRequestURL,
                                             pureRequestURL);
            }

            return;
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Session data is " + url.getExternalForm());
        }

        // Add the parameters from the session into the pure request url.
        Map parameterMap = pureRequestURL.getParameterMap();
        for (int i = 0; i < count; i += 1) {
            FieldDescriptor field = (FieldDescriptor) fields.get(i);
            if (logger.isDebugEnabled()) {
                logger.debug("Copying parameter(s) for " + field);
            }
            String name = field.getName();
            if (name != null) {
                String[] sessionValues = url.getParameterValues(name);
                // Don't overwrite values from the current request that haven't yet been stored in
                // the session. so:
                // - don't add empty parameters
View Full Code Here


        fdm.expects.getSessionFormData("s0").returns(sessionFormData).any();
        sessionFormData.expects.setFieldValue(URLConstants.ACTION_FORM_FRAGMENT, "http://www.volantis.com").any();

        for (int i = 0; i < SINGLE_DEFAULT_FIELDS.length; i++ ) {
            FieldDescriptor fd = new FieldDescriptor();
            fd.setName((String) SINGLE_DEFAULT_FIELDS[i][0]);
            fd.setType((FieldType) SINGLE_DEFAULT_FIELDS[i][1]);
            if(SINGLE_DEFAULT_FIELDS[i][1] instanceof ImplicitFieldType){
                fd.setInitialValue("Unreferenced value");
            }
            default_FD.addField(fd);
        }
    }
View Full Code Here

        fdm.expects.getSessionFormData("s0").returns(sessionFormData);
        sessionFormData.expects.setFieldValue(URLConstants.ACTION_FORM_FRAGMENT, "/delivery");      

        for (int i = 0; i < MULTIPLE_DEFAULT_FIELDS.length; i++ ) {
            FieldDescriptor fd = new FieldDescriptor();
            fd.setName((String) MULTIPLE_DEFAULT_FIELDS[i][0]);
            fd.setType((FieldType) MULTIPLE_DEFAULT_FIELDS[i][1]);
            if(MULTIPLE_DEFAULT_FIELDS[i][1] instanceof ImplicitFieldType){
                fd.setInitialValue("Unreferenced value - value");
            }
            default_FD.addField(fd);
        }

        for (int i = 0; i < MULTIPLE_MODEL2_FIELDS.length; i++ ) {
            FieldDescriptor fd = new FieldDescriptor();
            fd.setName((String) MULTIPLE_MODEL2_FIELDS[i][0]);
            fd.setType((FieldType) MULTIPLE_MODEL2_FIELDS[i][1]);
            if(MULTIPLE_MODEL2_FIELDS[i][1] instanceof ImplicitFieldType){
                fd.setInitialValue("UnreferencedValueTwoValue");
            }
            FD2.addField(fd);
        }

        for (int i = 0; i < MULTIPLE_MODEL3_FIELDS.length; i++ ) {
            FieldDescriptor fd = new FieldDescriptor();
            fd.setName((String) MULTIPLE_MODEL3_FIELDS[i][0]);
            fd.setType((FieldType) MULTIPLE_MODEL3_FIELDS[i][1]);
            FD3.addField(fd);
        }

    }
View Full Code Here

        }

        pattributes.setClientVariableName(clientVariableName);

        // Create the field descriptor.
        FieldDescriptor fieldDescriptor = new FieldDescriptor();
        fieldDescriptor.setName(name);
        fieldDescriptor.setType(ImplicitFieldType.getSingleton());
        fieldDescriptor.setInitialValue(value);

        // Add a reference to the field descriptor into the attributes.
        pattributes.setFieldDescriptor(fieldDescriptor);

        // Add the attributes to the list.
View Full Code Here

        openForm(attributes);

        for (int i = 0; i < count; i += 1) {
            XFFormFieldAttributes fieldAttributes
                = (XFFormFieldAttributes)fields.get(i);
            FieldDescriptor fieldDescriptor
                = fieldAttributes.getFieldDescriptor();
            FieldType fieldType = fieldDescriptor.getType();

            fieldType.doField(this, fieldAttributes);

            // Make sure that we make sure that we close any iterator pane
            // buffers.
View Full Code Here

            // Iterate over all the fields adding postfield tags to this action.
            List fields = fd.getFields();
            int count = fields.size();
            for (int i = 0; i < count; i += 1) {
                FieldDescriptor field = (FieldDescriptor) fields.get(i);

                final String fieldName = field.getName();
                if (fieldName != null) {
                    final String value;
                    // Ignore action fields when generating post fields (this
                    // one will have been added by #processPostFields).
                    if (field.getType() instanceof ActionFieldType) {
                        continue;
                    } else if (field.getType() instanceof ImplicitFieldType) {
                        if(null == field.getInitialValue()){
                            // null value is not-valid
                            value = "";
                        } else {
                            value = field.getInitialValue();                           
                        }
                    } else {
                        // The field is emulating an XForm control, so the
                        // value of the field is stored in a variable with the
                        // same name as the field.
                        value = variableStyle + field.getName() + variableStyle;
                    }

                    // Add a post field entry for the field.
                    final Element postField = domFactory.createElement();
                    postField.setName("postfield");
View Full Code Here

    protected void generateImplicitElements(XFormModel model,
            VolantisProtocol protocol) {
        Iterator itemIterator = model.getItemIterator();
        while (itemIterator.hasNext()) {
            final XFImplicitAttributes attributes;
            final FieldDescriptor fd = new FieldDescriptor();
            SIItem item = (SIItem)itemIterator.next();
            if (!item.isReferenced()) {
                // populate XFFormFieldAttributes
                attributes = new XFImplicitAttributes();
                attributes.setName(item.getName());
                attributes.setValue(item.getUnprocessedValue());
                attributes.setContainingXFFormName(
                        model.getXFFormAttributes().getName());

                // populate FieldDescriptor
                fd.setName(item.getName());
                fd.setType(ImplicitFieldType.getSingleton());
                fd.setInitialValue(item.getUnprocessedValue());

                // add the control to the model
                model.addControl(fd, attributes);

                // populate the XFormAttributes
View Full Code Here

                    NDimensionalIndex.ZERO_DIMENSIONS)
            .returns(formInstance).any();


        // Create descriptor for the upload element
        FieldDescriptor uploadDescriptor = new FieldDescriptor();
        uploadDescriptor.setType(UploadFieldType.getSingleton());
        uploadDescriptor.setName("fileToUpload");

        // Create descriptor for the enclosing form
        FormDescriptor formDescriptor = new FormDescriptor();
        formDescriptor.addField(uploadDescriptor);

        // Create atributes of the upload element
        uploadAttrs = new XFUploadAttributes();
        uploadAttrs.setFieldDescriptor(uploadDescriptor);
        uploadAttrs.setName(uploadDescriptor.getName());
        uploadAttrs.setEntryContainerInstance(paneInstance);

        // Create attributes of the enclosing form
        formAttrs =  new XFFormAttributes();
        formAttrs.setFormDescriptor(formDescriptor);
View Full Code Here

            // Set the namelist attribute to the fields defined in the
            // form descriptor.
            StringBuffer buffer = new StringBuffer(URLConstants.FORM_PARAMETER);
            for (Iterator i = fd.getFields().iterator(); i.hasNext();) {

                FieldDescriptor field = (FieldDescriptor)i.next();

                // Ignore other action fields when generating the field names.
                if (field.getType() instanceof ActionFieldType &&
                        element.getName().equalsIgnoreCase(field.getName())) {
                    continue;
                }

                // Make sure that the name is set before adding it.
                if (field.getName() != null) {
                    buffer.append(" ").append(field.getName());
                }
            }
            element.setAttribute("namelist", buffer.toString());
        }
    }
View Full Code Here

        int count = fields.size ();

        for (int i = 0; i < count; i += 1) {
          XFFormFieldAttributes fieldAttributes
              = (XFFormFieldAttributes) fields.get (i);
          FieldDescriptor fieldDescriptor
              = fieldAttributes.getFieldDescriptor ();

          //
          // We are only interested in action fields with names
          //
          if (fieldDescriptor.getType().equals(
              ActionFieldType.getSingleton()) &&
              fieldDescriptor.getName()!=null) {
            //
            // We only want to map fields that have an initial value, otherwise
            // we should default to caption (this is the default behaviour for
            // all protocols).
            //
            if (fieldDescriptor.getInitialValue()!=null) {
                TextAssetReference caption = fieldAttributes.getCaption();
                String captionString = getPlainText(caption);
                fieldDescriptor.setFieldTag(captionString);
              fieldAttributes.setFieldDescriptor(fieldDescriptor);
            }
          }
        }
        //
View Full Code Here

TOP

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

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.