Package org.ofbiz.widget.form

Examples of org.ofbiz.widget.form.ModelForm


    /* (non-Javadoc)
     * @see org.ofbiz.widget.form.FormStringRenderer#renderDropDownField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DropDownField)
     */
    public void renderDropDownField(StringBuffer buffer, Map context, DropDownField dropDownField) {
        ModelFormField modelFormField = dropDownField.getModelFormField();
        ModelForm modelForm = modelFormField.getModelForm();

        String event = modelFormField.getEvent();
        String action = modelFormField.getAction(context);

        buffer.append("<select");

        appendClassNames(buffer, context, modelFormField);

        buffer.append(" name=\"");
        buffer.append(modelFormField.getParameterName(context));
        buffer.append('"');

        String idName = modelFormField.getIdName();
        if (UtilValidate.isNotEmpty(idName)) {
            buffer.append(" id=\"");
            buffer.append(idName);
            buffer.append('"');
        }

        if (dropDownField.isAllowMultiple()) {
            buffer.append(" multiple=\"multiple\"");
        }
       
        int otherFieldSize = dropDownField.getOtherFieldSize();
        String otherFieldName = dropDownField.getParameterNameOther(context);
        if (otherFieldSize > 0) {
            //buffer.append(" onchange=\"alert('ONCHANGE, process_choice:' + process_choice)\"");
            //buffer.append(" onchange='test_js()' ");
            buffer.append(" onchange=\"process_choice(this,document.");
            buffer.append(modelForm.getName());
            buffer.append(".");
            buffer.append(otherFieldName);
            buffer.append(")\" ");
        }


        if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
            buffer.append(" ");
            buffer.append(event);
            buffer.append("=\"");
            buffer.append(action);
            buffer.append('"');
        }

        buffer.append(" size=\"").append(dropDownField.getSize()).append("\">");

        String currentValue = modelFormField.getEntry(context);
        List allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator());

        // if the current value should go first, stick it in
        if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) {
            buffer.append("<option");
            buffer.append(" selected=\"selected\"");
            buffer.append(" value=\"");
            buffer.append(currentValue);
            buffer.append("\">");
            String explicitDescription = dropDownField.getCurrentDescription(context);
            if (UtilValidate.isNotEmpty(explicitDescription)) {
                buffer.append(explicitDescription);
            } else {
                buffer.append(ModelFormField.FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues));
            }
            buffer.append("</option>");

            // add a "separator" option
            buffer.append("<option value=\"");
            buffer.append(currentValue);
            buffer.append("\">---</option>");
        }

        // if allow empty is true, add an empty option
        if (dropDownField.isAllowEmpty()) {
            buffer.append("<option value=\"\">&nbsp;</option>");
        }

        // list out all options according to the option list
        Iterator optionValueIter = allOptionValues.iterator();
        while (optionValueIter.hasNext()) {
            ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
            String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context);
            buffer.append("<option");
            // if current value should be selected in the list, select it
            if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey()) && "selected".equals(dropDownField.getCurrent())) {
                buffer.append(" selected=\"selected\"");
            } else if (UtilValidate.isEmpty(currentValue) && noCurrentSelectedKey != null && noCurrentSelectedKey.equals(optionValue.getKey())) {
                buffer.append(" selected=\"selected\"");
            }
            buffer.append(" value=\"");
            buffer.append(optionValue.getKey());
            buffer.append("\">");
            buffer.append(optionValue.getDescription());
            buffer.append("</option>");
        }

        buffer.append("</select>");

        // Adapted from work by Yucca Korpela
        // http://www.cs.tut.fi/~jkorpela/forms/combo.html
        if (otherFieldSize > 0) {
       
            String fieldName = modelFormField.getParameterName(context);
            Map dataMap = modelFormField.getMap(context);
            if (dataMap == null) {
                dataMap = context;
            }
            Object otherValueObj = dataMap.get(otherFieldName);
            String otherValue = (otherValueObj == null) ? "" : otherValueObj.toString();
           
            buffer.append("<noscript>");
            buffer.append("<input type='text' name='");
            buffer.append(otherFieldName);
            buffer.append("'/> ");
            buffer.append("</noscript>");
            buffer.append("\n<script type='text/javascript' language='JavaScript'><!--");
            buffer.append("\ndisa = ' disabled';");
            buffer.append("\nif(other_choice(document.");
            buffer.append(modelForm.getName());
            buffer.append(".");
            buffer.append(fieldName);
            buffer.append(")) disa = '';");
            buffer.append("\ndocument.write(\"<input type=");
            buffer.append("'text' name='");
            buffer.append(otherFieldName);
            buffer.append("' value='");
            buffer.append(otherValue);
            buffer.append("' size='");
            buffer.append(otherFieldSize);
            buffer.append("' ");
            buffer.append("\" +disa+ \" onfocus='check_choice(document.");
            buffer.append(modelForm.getName());
            buffer.append(".");
            buffer.append(fieldName);
            buffer.append(")'/>\");");
            buffer.append("\nif(disa && document.styleSheets)");
            buffer.append(" document.");
            buffer.append(modelForm.getName());
            buffer.append(".");
            buffer.append(otherFieldName);
            buffer.append(".style.visibility  = 'hidden';");
            buffer.append("\n//--></script>");
        }
View Full Code Here


    /* (non-Javadoc)
     * @see org.ofbiz.widget.form.FormStringRenderer#renderCheckField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.CheckField)
     */
    public void renderCheckField(StringBuffer buffer, Map context, CheckField checkField) {
        ModelFormField modelFormField = checkField.getModelFormField();
        ModelForm modelForm = modelFormField.getModelForm();
        String currentValue = modelFormField.getEntry(context);
        Boolean allChecked = checkField.isAllChecked(context);
       
        List allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator());
        String event = modelFormField.getEvent();
        String action = modelFormField.getAction(context);

        // list out all options according to the option list
        Iterator optionValueIter = allOptionValues.iterator();
View Full Code Here

    /* (non-Javadoc)
     * @see org.ofbiz.widget.form.FormStringRenderer#renderRadioField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.RadioField)
     */
    public void renderRadioField(StringBuffer buffer, Map context, RadioField radioField) {
        ModelFormField modelFormField = radioField.getModelFormField();
        ModelForm modelForm = modelFormField.getModelForm();
        List allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator());
        String currentValue = modelFormField.getEntry(context);
        String event = modelFormField.getEvent();
        String action = modelFormField.getAction(context);

        // list out all options according to the option list
View Full Code Here

    /* (non-Javadoc)
     * @see org.ofbiz.widget.form.FormStringRenderer#renderSubmitField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.SubmitField)
     */
    public void renderSubmitField(StringBuffer buffer, Map context, SubmitField submitField) {
        ModelFormField modelFormField = submitField.getModelFormField();
        ModelForm modelForm = modelFormField.getModelForm();
        String singleClickAction = " onClick=\"javascript:submitFormDisableButton(this)\" ";
        String event = null;
        String action = null;       

        if ("text-link".equals(submitField.getButtonType())) {
            buffer.append("<a");

            appendClassNames(buffer, context, modelFormField);

            buffer.append(" href=\"javascript:document.");
            buffer.append(modelForm.getCurrentFormName(context));
            buffer.append(".submit()\">");

            buffer.append(modelFormField.getTitle(context));

            buffer.append("</a>");
View Full Code Here

        this.appendWhitespace(buffer);
    }

    public void renderDropDownField(StringBuffer buffer, Map context, DropDownField dropDownField) {
        ModelFormField modelFormField = dropDownField.getModelFormField();
        ModelForm modelForm = modelFormField.getModelForm();
        String currentValue = modelFormField.getEntry(context);
        List allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator());
        // if the current value should go first, display it
        if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) {
            String explicitDescription = dropDownField.getCurrentDescription(context);
            if (UtilValidate.isNotEmpty(explicitDescription)) {
                this.makeBlockString(buffer, modelFormField.getWidgetStyle(), explicitDescription);
View Full Code Here

        this.appendWhitespace(buffer);
    }

    public void renderDropDownField(StringBuffer buffer, Map context, DropDownField dropDownField) {
        ModelFormField modelFormField = dropDownField.getModelFormField();
        ModelForm modelForm = modelFormField.getModelForm();
        String currentValue = modelFormField.getEntry(context);
        List allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator());
        // if the current value should go first, display it
        if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) {
            String explicitDescription = dropDownField.getCurrentDescription(context);
            if (UtilValidate.isNotEmpty(explicitDescription)) {
                this.makeTextString(buffer, modelFormField.getWidgetStyle(), explicitDescription);
View Full Code Here

TOP

Related Classes of org.ofbiz.widget.form.ModelForm

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.