Example usage for java.io StringWriter append

List of usage examples for java.io StringWriter append

Introduction

In this page you can find the example usage for java.io StringWriter append.

Prototype

public StringWriter append(char c) 

Source Link

Document

Appends the specified character to this writer.

Usage

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField)
        throws IOException {
    ModelFormField modelFormField = rangeFindField.getModelFormField();
    Locale locale = (Locale) context.get("locale");
    String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
    String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
    String opGreaterThanEquals = UtilProperties.getMessage("conditional", "greater_than_equals", locale);
    String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
    String opLessThanEquals = UtilProperties.getMessage("conditional", "less_than_equals", locale);
    //String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);

    String className = "";
    String alert = "false";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }//from  w  ww.  j  av  a 2 s .co m
    }
    String name = modelFormField.getParameterName(context);
    String size = Integer.toString(rangeFindField.getSize());
    String value = modelFormField.getEntry(context, rangeFindField.getDefaultValue(context));
    if (value == null) {
        value = "";
    }
    Integer maxlength = rangeFindField.getMaxlength();
    String autocomplete = "";

    if (!rangeFindField.getClientAutocompleteField()) {
        autocomplete = "off";
    }
    String titleStyle = modelFormField.getTitleStyle();

    if (titleStyle == null) {
        titleStyle = "";
    }

    String defaultOptionFrom = rangeFindField.getDefaultOptionFrom();

    String value2 = modelFormField.getEntry(context);
    if (value2 == null) {
        value2 = "";
    }
    String defaultOptionThru = rangeFindField.getDefaultOptionThru();

    StringWriter sr = new StringWriter();
    sr.append("<@renderRangeFindField ");
    sr.append(" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" size=\"");
    sr.append(size);
    sr.append("\" maxlength=\"");
    if (maxlength != null) {
        sr.append(Integer.toString(maxlength));
    }
    sr.append("\" autocomplete=\"");
    sr.append(autocomplete);
    sr.append("\" titleStyle=\"");
    sr.append(titleStyle);
    sr.append("\" defaultOptionFrom=\"");
    sr.append(defaultOptionFrom);
    sr.append("\" opEquals=\"");
    sr.append(opEquals);
    sr.append("\" opGreaterThan=\"");
    sr.append(opGreaterThan);
    sr.append("\" opGreaterThanEquals=\"");
    sr.append(opGreaterThanEquals);
    sr.append("\" opLessThan=\"");
    sr.append(opLessThan);
    sr.append("\" opLessThanEquals=\"");
    sr.append(opLessThanEquals);
    sr.append("\" value2=\"");
    sr.append(value2);
    sr.append("\" defaultOptionThru=\"");
    sr.append(defaultOptionThru);
    sr.append("\" />");
    executeMacro(writer, sr.toString());

    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField,
        String titleText) throws IOException {
    boolean ajaxEnabled = false;
    ModelForm modelForm = modelFormField.getModelForm();
    List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas();
    String targetService = modelForm.getPaginateTarget(context);
    if (this.javaScriptEnabled) {
        if (UtilValidate.isNotEmpty(updateAreas)) {
            ajaxEnabled = true;/* w  w  w.j ava2  s  .  co m*/
        }
    }
    if (targetService == null) {
        targetService = "${targetService}";
    }
    if (UtilValidate.isEmpty(targetService) && updateAreas == null) {
        Debug.logWarning("Cannot sort because TargetService is empty for the form: " + modelForm.getName(),
                module);
        return;
    }

    String str = (String) context.get("_QBESTRING_");
    String oldSortField = modelForm.getSortField(context);
    String sortFieldStyle = modelFormField.getSortFieldStyle();

    // if the entry-name is defined use this instead of field name
    String columnField = modelFormField.getEntryName();
    if (UtilValidate.isEmpty(columnField)) {
        columnField = modelFormField.getFieldName();
    }

    // switch beetween asc/desc order
    String newSortField = columnField;
    if (UtilValidate.isNotEmpty(oldSortField)) {
        if (oldSortField.equals(columnField)) {
            newSortField = "-" + columnField;
            sortFieldStyle = modelFormField.getSortFieldStyleDesc();
        } else if (oldSortField.equals("-" + columnField)) {
            newSortField = columnField;
            sortFieldStyle = modelFormField.getSortFieldStyleAsc();
        }
    }

    //  strip sortField param from the query string
    HashSet<String> paramName = new HashSet<String>();
    paramName.add("sortField");
    String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName);
    String urlPath = UtilHttp.removeQueryStringFromTarget(targetService);
    String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService);

    if (UtilValidate.isNotEmpty(queryString)) {
        queryString = UtilHttp.encodeAmpersands(queryString);
    }

    if (prepLinkText == null) {
        prepLinkText = "";
    }
    if (prepLinkText.indexOf("?") < 0) {
        prepLinkText += "?";
    } else if (!prepLinkText.endsWith("?")) {
        prepLinkText += "&amp;";
    }
    if (!UtilValidate.isEmpty(queryString) && !queryString.equals("null")) {
        prepLinkText += queryString + "&amp;";
    }
    prepLinkText += "sortField" + "=" + newSortField;
    if (ajaxEnabled) {
        prepLinkText = prepLinkText.replace("?", "");
        prepLinkText = prepLinkText.replace("&amp;", "&");
    }
    String linkUrl = "";
    if (ajaxEnabled) {
        linkUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText, context);
    } else {
        linkUrl = rh.makeLink(this.request, this.response, urlPath + prepLinkText);
    }

    StringWriter sr = new StringWriter();
    sr.append("<@renderSortField ");
    sr.append(" style=\"");
    sr.append(sortFieldStyle);
    sr.append("\" title=\"");
    sr.append(titleText);
    sr.append("\" linkUrl=\"");
    sr.append(linkUrl);
    sr.append("\" ajaxEnabled=");
    sr.append(Boolean.toString(ajaxEnabled));
    sr.append(" />");
    executeMacro(writer, sr.toString());

}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField)
        throws IOException {
    ModelFormField modelFormField = textFindField.getModelFormField();

    String defaultOption = textFindField.getDefaultOption(context);
    String className = "";
    String alert = "false";
    String opEquals = "";
    String opBeginsWith = "";
    String opContains = "";
    String opIsEmpty = "";
    String opNotEqual = "";
    String name = modelFormField.getParameterName(context);
    String size = Integer.toString(textFindField.getSize());
    String maxlength = "";
    String autocomplete = "";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }// w w  w .j  a  v a 2 s .  c  o m
    }
    Locale locale = (Locale) context.get("locale");
    if (!textFindField.getHideOptions()) {
        opEquals = UtilProperties.getMessage("conditional", "equals", locale);
        opBeginsWith = UtilProperties.getMessage("conditional", "begins_with", locale);
        opContains = UtilProperties.getMessage("conditional", "contains", locale);
        opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
        opNotEqual = UtilProperties.getMessage("conditional", "not_equal", locale);
    }

    String value = modelFormField.getEntry(context, textFindField.getDefaultValue(context));
    if (value == null) {
        value = "";
    }

    if (textFindField.getMaxlength() != null) {
        maxlength = textFindField.getMaxlength().toString();
    }

    if (!textFindField.getClientAutocompleteField()) {
        autocomplete = "off";
    }
    String titleStyle = "";
    if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
        titleStyle = modelFormField.getTitleStyle();
    }

    String ignoreCase = UtilProperties.getMessage("conditional", "ignore_case", locale);
    boolean ignCase = textFindField.getIgnoreCase(context);
    boolean hideIgnoreCase = textFindField.getHideIgnoreCase();
    StringWriter sr = new StringWriter();
    sr.append("<@renderTextFindField ");
    sr.append(" name=\"");
    sr.append(name);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" defaultOption=\"");
    sr.append(defaultOption);
    sr.append("\" opEquals=\"");
    sr.append(opEquals);
    sr.append("\" opBeginsWith=\"");
    sr.append(opBeginsWith);
    sr.append("\" opContains=\"");
    sr.append(opContains);
    sr.append("\" opIsEmpty=\"");
    sr.append(opIsEmpty);
    sr.append("\" opNotEqual=\"");
    sr.append(opNotEqual);
    sr.append("\" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" size=\"");
    sr.append(size);
    sr.append("\" maxlength=\"");
    sr.append(maxlength);
    sr.append("\" autocomplete=\"");
    sr.append(autocomplete);
    sr.append("\" titleStyle=\"");
    sr.append(titleStyle);
    sr.append("\" hideIgnoreCase=");
    sr.append(Boolean.toString(hideIgnoreCase));
    sr.append(" ignCase=");
    sr.append(Boolean.toString(ignCase));
    sr.append(" ignoreCase=\"");
    sr.append(ignoreCase);
    sr.append("\" />");
    executeMacro(writer, sr.toString());

    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderTextField(Appendable writer, Map<String, Object> context, TextField textField)
        throws IOException {
    ModelFormField modelFormField = textField.getModelFormField();
    String name = modelFormField.getParameterName(context);
    String className = "";
    String alert = "false";
    String mask = "";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }//from  w  w w  . j a v a  2  s. c om
    }

    String value = modelFormField.getEntry(context, textField.getDefaultValue(context));
    String textSize = Integer.toString(textField.getSize());
    String maxlength = "";
    if (textField.getMaxlength() != null) {
        maxlength = Integer.toString(textField.getMaxlength());
    }
    String event = modelFormField.getEvent();
    String action = modelFormField.getAction(context);
    String id = modelFormField.getCurrentContainerId(context);
    String clientAutocomplete = "false";

    //check for required field style on single forms
    if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
        String requiredStyle = modelFormField.getRequiredFieldStyle();
        if (UtilValidate.isEmpty(requiredStyle))
            requiredStyle = "required";
        if (UtilValidate.isEmpty(className))
            className = requiredStyle;
        else
            className = requiredStyle + " " + className;
    }

    List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas();
    boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled;
    if (textField.getClientAutocompleteField() || ajaxEnabled) {
        clientAutocomplete = "true";
    }

    if (UtilValidate.isNotEmpty(textField.getMask())) {
        mask = textField.getMask();
    }

    String ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
    boolean disabled = textField.disabled;

    StringWriter sr = new StringWriter();
    sr.append("<@renderTextField ");
    sr.append("name=\"");
    sr.append(name);
    sr.append("\" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" textSize=\"");
    sr.append(textSize);
    sr.append("\" maxlength=\"");
    sr.append(maxlength);
    sr.append("\" id=\"");
    sr.append(id);
    sr.append("\" event=\"");
    if (event != null) {
        sr.append(event);
    }
    sr.append("\" action=\"");
    if (action != null) {
        sr.append(action);
    }
    sr.append("\" disabled=");
    sr.append(Boolean.toString(disabled));

    sr.append(" clientAutocomplete=\"");
    sr.append(clientAutocomplete);
    sr.append("\" ajaxUrl=\"");
    sr.append(ajaxUrl);
    sr.append("\" ajaxEnabled=");
    sr.append(Boolean.toString(ajaxEnabled));
    sr.append(" mask=\"");
    sr.append(mask);
    sr.append("\" />");
    executeMacro(writer, sr.toString());

    ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink();
    if (subHyperlink != null && subHyperlink.shouldUse(context)) {
        makeHyperlinkString(writer, subHyperlink, context);
    }
    this.addAsterisks(writer, context, modelFormField);
    this.appendTooltip(writer, context, modelFormField);
}

From source file:eu.sisob.uma.extractors.adhoc.cvfilesinside.InternalCVFilesExtractor.java

/**
 *
 * @param input_file/*  w w  w .  j a  v  a2 s. c  o m*/
 * @param data_dir
 * @param output_file
 * @param error_sw
 */
public static void extract_cv_files(File input_file, File data_dir,
        File output_file/*, File output_file_2, File results_dir,*/, StringWriter error_sw) {
    CSVReader reader = null;
    try {
        reader = new CSVReader(new FileReader(input_file), CSV_SEPARATOR);
    } catch (FileNotFoundException ex) {
        Logger.getRootLogger().error("Error reading " + input_file.getName() + " - " + ex.toString());
    }

    int idStaffIdentifier = -1;
    int idName = -1;
    int idFirstName = -1;
    int idLastName = -1;
    int idInitials = -1;
    int idUnitOfAssessment_Description = -1;
    int idInstitutionName = -1;
    int idWebAddress = -1;
    int idResearchGroupDescription = -1;
    int idResearcherWebAddress = -1;
    int idResearcherWebAddressType = -1;
    int idResearcherWebAddressExt = -1;
    int idScoreUrl = -1;
    int idEmail = -1;
    int idScoreEmail = -1;

    String[] nextLine;
    try {
        if ((nextLine = reader.readNext()) != null) {
            //Locate indexes            
            //Locate indexes                        
            for (int i = 0; i < nextLine.length; i++) {
                String column_name = nextLine[i];
                if (column_name.equals(FileFormatConversor.CSV_COL_ID))
                    idStaffIdentifier = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_NAME))
                    idName = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_FIRSTNAME))
                    idFirstName = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_LASTNAME))
                    idLastName = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_INITIALS))
                    idInitials = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_SUBJECT))
                    idUnitOfAssessment_Description = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_INSTITUTION_NAME))
                    idInstitutionName = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_INSTITUTION_URL))
                    idWebAddress = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_RESEARCHER_PAGE_URL))
                    idResearcherWebAddress = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_RESEARCHER_PAGE_TYPE))
                    idResearcherWebAddressType = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_RESEARCHER_PAGE_EXT))
                    idResearcherWebAddressExt = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_SCORE_URL))
                    idScoreUrl = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_EMAIL))
                    idEmail = i;
                else if (column_name.equals(FileFormatConversor.CSV_COL_SCORE_EMAIL))
                    idScoreEmail = i;
            }
        }
    } catch (Exception ex) {
        String error_msg = "Error reading headers of " + input_file.getName();
        Logger.getRootLogger().error(error_msg + " - " + ex.toString());
        if (error_sw != null)
            error_sw.append(error_msg + "\r\n");

        return;
    }

    if (idResearcherWebAddress != -1 && idResearcherWebAddressType != -1 && idResearcherWebAddressExt != -1
            && idStaffIdentifier != -1 && idLastName != -1 && idInitials != -1) {
        if (true) {
            try {
                String header = "";
                header += "\"" + FileFormatConversor.CSV_COL_ID + "\"" + CSV_SEPARATOR;
                header += "\"" + FileFormatConversor.CSV_COL_LASTNAME + "\"" + CSV_SEPARATOR;
                header += "\"" + FileFormatConversor.CSV_COL_INITIALS + "\"" + CSV_SEPARATOR;
                if (idFirstName != -1)
                    header += "\"" + FileFormatConversor.CSV_COL_FIRSTNAME + "\"" + CSV_SEPARATOR;
                if (idName != -1)
                    header += "\"" + FileFormatConversor.CSV_COL_NAME + "\"" + CSV_SEPARATOR;
                if (idEmail != -1)
                    header += "\"" + FileFormatConversor.CSV_COL_EMAIL + "\"" + CSV_SEPARATOR;
                if (idInstitutionName != -1)
                    header += "\"" + FileFormatConversor.CSV_COL_INSTITUTION_NAME + "\"" + CSV_SEPARATOR;
                if (idWebAddress != -1)
                    header += "\"" + FileFormatConversor.CSV_COL_INSTITUTION_URL + "\"" + CSV_SEPARATOR;
                header += "\"" + FileFormatConversor.CSV_COL_RESEARCHER_PAGE_URL + "\"" + CSV_SEPARATOR;
                header += "\"" + FileFormatConversor.CSV_COL_RESEARCHER_PAGE_EXT + "\"" + CSV_SEPARATOR;
                header += "\"" + FileFormatConversor.CSV_COL_RESEARCHER_PAGE_TYPE + "\"" + CSV_SEPARATOR;
                header += "\"" + FileFormatConversor.CSV_COL_SCORE_URL + "\"" + CSV_SEPARATOR;
                if (idScoreEmail != -1)
                    header += "\"" + FileFormatConversor.CSV_COL_SCORE_EMAIL + "\"" + CSV_SEPARATOR;
                header += "\r\n";
                FileUtils.write(output_file, header, "UTF-8", false);
                // DOWNLOAD HERE THE HOME PAGE 
                //FileUtils.write(output_file_2, header, "UTF-8", false);

            } catch (IOException ex) {
                Logger.getLogger("root").error(ex.toString());
                error_sw.append("Error creating output files\r\n");
            }
        }

        try {
            //                DOWNLOAD HERE THE HOME PAGE 
            //                if(!results_dir.exists())
            //                    results_dir.mkdirs();                
            //                File homepage_results_dirs = new File(results_dir, "HOMEPAGE");
            //                if(!homepage_results_dirs.exists())
            //                    homepage_results_dirs.mkdirs();
            //if(!test_only_output)
            {
                Pattern p1 = Pattern.compile("([a-zA-Z0-9#._-]+)+");

                while ((nextLine = reader.readNext()) != null) {
                    nextLine[idLastName] = nextLine[idLastName].replaceAll("[^a-zA-Z]", " ").toLowerCase();
                    nextLine[idInitials] = nextLine[idInitials].replaceAll("[^a-zA-Z]", " ").toLowerCase();
                    if (idFirstName != -1)
                        nextLine[idFirstName] = nextLine[idFirstName].replaceAll("[^a-zA-Z]", " ")
                                .toLowerCase();
                    if (idName != -1)
                        nextLine[idName] = nextLine[idName].replaceAll("[^a-zA-Z]", " ").toLowerCase();

                    Document content = null;
                    String researcher_page_url = nextLine[idResearcherWebAddress];
                    File temp_file = null;
                    if (p1.matcher(researcher_page_url).matches()) {

                    } else {

                        try {

                            Logger.getRootLogger().info("Reading " + researcher_page_url);

                            temp_file = File.createTempFile("internal-cv-files-", ".tmp");
                            URL fetched_url = Downloader.fetchURL(researcher_page_url);
                            FileUtils.copyURLToFile(fetched_url, temp_file);
                            long sizeInBytes = temp_file.length();
                            long sizeInMb = sizeInBytes / (1024 * 1024);
                            if (sizeInMb > 100) {
                                content = null;
                            } else {
                                String text_content = FileUtils.readFileToString(temp_file);
                                String check_string = "";
                                if (text_content.length() <= 100) {
                                    check_string = text_content.substring(0, text_content.length());
                                } else {
                                    check_string = text_content.substring(0, 100);
                                }
                                if (check_string.toLowerCase().contains("html")) {
                                    content = Jsoup.parse(text_content);
                                    content.setBaseUri(researcher_page_url);
                                    //                                          DOWNLOAD HERE THE HOME PAGE                                        
                                    //                                        String filename = nextLine[idStaffIdentifier] + "_HOMEPAGE_" + MD5(researcher_page_url) + ".html";
                                    //                                        FileUtils.copyFile(temp_file, new File(homepage_results_dirs, filename));                                        
                                    //                                        
                                    //                                        String result = "";                        
                                    //                                        result += "\"" + nextLine[idStaffIdentifier] + "\"" + CSV_SEPARATOR;
                                    //                                        result += "\"" + nextLine[idLastName] + "\"" + CSV_SEPARATOR;
                                    //                                        result += "\"" + nextLine[idInitials] + "\"" + CSV_SEPARATOR;                                    
                                    //                                        if(idFirstName != -1) result += "\"" + nextLine[idFirstName] + "\"" + CSV_SEPARATOR;  
                                    //                                        if(idName != -1) result += "\"" + nextLine[idName] + "\"" + CSV_SEPARATOR;  
                                    //                                        if(idEmail != -1) result += "\"" + nextLine[idEmail] + "\"" + CSV_SEPARATOR; 
                                    //                                        if(idInstitutionName != -1) result += "\"" + nextLine[idInstitutionName] + "\"" + CSV_SEPARATOR;  
                                    //                                        if(idWebAddress != -1) result += "\"" + nextLine[idWebAddress] + "\"" + CSV_SEPARATOR;                 
                                    //                                        result += "\"" + filename + "\"" + CSV_SEPARATOR;
                                    //                                        result += "\"" + nextLine[idResearcherWebAddressType] + "\"" + CSV_SEPARATOR;
                                    //                                        result += "\"" + nextLine[idResearcherWebAddressExt] + "\"" + CSV_SEPARATOR;
                                    //                                        result += "\"" + (idScoreUrl != -1 ? nextLine[idScoreUrl] : "") + "\"" + CSV_SEPARATOR;
                                    //                                        if(idScoreEmail != -1) result += "\"" + nextLine[idScoreEmail] + "\"" + CSV_SEPARATOR; 
                                    //                                        result += "\r\n";
                                    //
                                    //                                        try {
                                    //                                            FileUtils.write(output_file_2, result, "UTF-8", true);
                                    //                                        } catch (IOException ex) {
                                    //                                            Logger.getLogger("root").error(ex.toString());
                                    //                                        }
                                } else {
                                    throw new Exception(researcher_page_url + " is not html document");
                                }
                            }

                        } catch (Exception ex) {
                            Logger.getLogger("root").error("" + researcher_page_url + " could not loaded", ex);
                            error_sw.append("" + researcher_page_url + " could not loaded");
                            content = null;
                        } catch (java.lang.OutOfMemoryError ex2) {
                            Logger.getLogger("root")
                                    .error("" + researcher_page_url + " could not loaded (out of memory)", ex2);
                            error_sw.append("" + researcher_page_url + " could not loaded (out of memory)");
                            content = null;
                        } finally {
                            if (temp_file != null)
                                temp_file.delete();
                        }

                    }
                    //Add sources to output
                    {
                        String result = "";
                        result += "\"" + nextLine[idStaffIdentifier] + "\"" + CSV_SEPARATOR;
                        result += "\"" + nextLine[idLastName] + "\"" + CSV_SEPARATOR;
                        result += "\"" + nextLine[idInitials] + "\"" + CSV_SEPARATOR;
                        if (idFirstName != -1)
                            result += "\"" + nextLine[idFirstName] + "\"" + CSV_SEPARATOR;
                        if (idName != -1)
                            result += "\"" + nextLine[idName] + "\"" + CSV_SEPARATOR;
                        if (idEmail != -1)
                            result += "\"" + nextLine[idEmail] + "\"" + CSV_SEPARATOR;
                        if (idInstitutionName != -1)
                            result += "\"" + nextLine[idInstitutionName] + "\"" + CSV_SEPARATOR;
                        if (idWebAddress != -1)
                            result += "\"" + nextLine[idWebAddress] + "\"" + CSV_SEPARATOR;
                        result += "\"" + nextLine[idResearcherWebAddress] + "\"" + CSV_SEPARATOR;
                        result += "\"" + nextLine[idResearcherWebAddressExt] + "\"" + CSV_SEPARATOR;
                        result += "\"HOMEPAGE\"" + CSV_SEPARATOR;
                        result += "\"" + (idScoreUrl != -1 ? nextLine[idScoreUrl] : "") + "\"" + CSV_SEPARATOR;
                        if (idScoreEmail != -1)
                            result += "\"" + nextLine[idScoreEmail] + "\"" + CSV_SEPARATOR;
                        result += "\r\n";

                        try {
                            FileUtils.write(output_file, result, "UTF-8", true);
                        } catch (IOException ex) {
                            Logger.getLogger("root").error(ex.toString());
                        }
                    }

                    if (content != null) {

                        Elements links = content.select("a[href]");
                        Elements links_worepeat = new Elements();

                        for (Element link : links) {

                            boolean b = false;
                            for (Element link_worepeat : links_worepeat) {
                                if (link.absUrl("href").equals(link_worepeat.absUrl("href"))) {
                                    b = true;
                                    break;
                                }
                            }

                            if (!b)
                                links_worepeat.add(link);

                        }

                        for (Element link : links_worepeat) {

                            boolean b = false;
                            link.setBaseUri(researcher_page_url);
                            String clean_name_1 = link.text().replaceAll("[^\\w\\s]", "").toLowerCase();
                            for (String k : cv_keywords_in_name_list) {
                                if (clean_name_1.contains(k)) {
                                    b = true;
                                    break;
                                }
                            }
                            if (b) {
                                Logger.getRootLogger()
                                        .info("CV found " + link.absUrl("href") + " (" + link.text() + ")");
                                String href = link.absUrl("href");

                                String ext = "";
                                String score = "";
                                String type = "CV";

                                if (link.absUrl("href").endsWith(".pdf"))
                                    ext = "PDF";
                                else if (link.absUrl("href").endsWith(".doc"))
                                    ext = "DOC";
                                else if (link.absUrl("href").endsWith(".docx"))
                                    ext = "DOCX";
                                else if (link.absUrl("href").endsWith(".rtf"))
                                    ext = "RTF";
                                else if (link.absUrl("href").endsWith(".txt"))
                                    ext = "TXT";
                                else
                                    ext = "HTML";

                                if (ext.equals("HTML")) {
                                    score = "B";
                                } else {
                                    score = "A";
                                }

                                String result = "";
                                result += "\"" + nextLine[idStaffIdentifier] + "\"" + CSV_SEPARATOR;
                                result += "\"" + nextLine[idLastName] + "\"" + CSV_SEPARATOR;
                                result += "\"" + nextLine[idInitials] + "\"" + CSV_SEPARATOR;
                                if (idFirstName != -1)
                                    result += "\"" + nextLine[idFirstName] + "\"" + CSV_SEPARATOR;
                                if (idName != -1)
                                    result += "\"" + nextLine[idName] + "\"" + CSV_SEPARATOR;
                                if (idEmail != -1)
                                    result += "\"" + nextLine[idEmail] + "\"" + CSV_SEPARATOR;
                                if (idInstitutionName != -1)
                                    result += "\"" + nextLine[idInstitutionName] + "\"" + CSV_SEPARATOR;
                                if (idWebAddress != -1)
                                    result += "\"" + href + "\"" + CSV_SEPARATOR;
                                result += "\"" + href + "\"" + CSV_SEPARATOR;
                                result += "\"" + ext + "\"" + CSV_SEPARATOR;
                                result += "\"" + type + "\"" + CSV_SEPARATOR;
                                result += "\"" + score + "\"" + CSV_SEPARATOR;
                                if (idScoreEmail != -1)
                                    result += "\"" + nextLine[idScoreEmail] + "\"" + CSV_SEPARATOR;
                                result += "\r\n";

                                try {
                                    FileUtils.write(output_file, result, "UTF-8", true);
                                } catch (IOException ex) {
                                    Logger.getLogger("root").error(ex.toString());
                                }

                            }

                            b = false;
                            link.setBaseUri(researcher_page_url);
                            clean_name_1 = link.text().replaceAll("[^\\w\\s]", "").toLowerCase();
                            for (String k : pub_keywords_in_name_list) {
                                if (clean_name_1.contains(k)) {
                                    b = true;
                                    break;
                                }
                            }
                            if (b) {
                                Logger.getRootLogger()
                                        .info("PUB found " + link.absUrl("href") + " (" + link.text() + ")");
                                String href = link.absUrl("href");

                                String ext = "";
                                String score = "";
                                String type = "PUB";

                                if (link.absUrl("href").endsWith(".pdf"))
                                    ext = "PDF";
                                else if (link.absUrl("href").endsWith(".doc"))
                                    ext = "DOC";
                                else if (link.absUrl("href").endsWith(".docx"))
                                    ext = "DOCX";
                                else if (link.absUrl("href").endsWith(".rtf"))
                                    ext = "RTF";
                                else if (link.absUrl("href").endsWith(".txt"))
                                    ext = "TXT";
                                else
                                    ext = "HTML";

                                if (ext.equals("HTML")) {
                                    score = "-";
                                } else {
                                    score = "-";
                                }

                                String result = "";
                                result += "\"" + nextLine[idStaffIdentifier] + "\"" + CSV_SEPARATOR;
                                result += "\"" + nextLine[idLastName] + "\"" + CSV_SEPARATOR;
                                result += "\"" + nextLine[idInitials] + "\"" + CSV_SEPARATOR;
                                if (idFirstName != -1)
                                    result += "\"" + nextLine[idFirstName] + "\"" + CSV_SEPARATOR;
                                if (idName != -1)
                                    result += "\"" + nextLine[idName] + "\"" + CSV_SEPARATOR;
                                if (idEmail != -1)
                                    result += "\"" + nextLine[idEmail] + "\"" + CSV_SEPARATOR;
                                if (idInstitutionName != -1)
                                    result += "\"" + nextLine[idInstitutionName] + "\"" + CSV_SEPARATOR;
                                if (idWebAddress != -1)
                                    result += "\"" + href + "\"" + CSV_SEPARATOR;
                                result += "\"" + href + "\"" + CSV_SEPARATOR;
                                result += "\"" + ext + "\"" + CSV_SEPARATOR;
                                result += "\"" + type + "\"" + CSV_SEPARATOR;
                                result += "\"" + score + "\"" + CSV_SEPARATOR;
                                if (idScoreEmail != -1)
                                    result += "\"" + nextLine[idScoreEmail] + "\"" + CSV_SEPARATOR;
                                result += "\r\n";

                                try {
                                    FileUtils.write(output_file, result, "UTF-8", true);
                                } catch (IOException ex) {
                                    Logger.getLogger("root").error(ex.toString());
                                }

                            }
                        }

                    }
                }

                reader.close();

            }

            //                    reader = null;
            //                    try {
            //                        reader = new CSVReader(new FileReader(output_file), CSV_SEPARATOR);
            //                    } catch (FileNotFoundException ex) {
            //                        Logger.getRootLogger().error("Error reading " + input_file.getName() + " - " + ex.toString());
            //                    }
            //
            //                    reader.readNext();
            //
            //                    int newIdResearcherWebpage = 3;
            //                    if(idFirstName != -1) newIdResearcherWebpage++; 
            //                    if(idName != -1) newIdResearcherWebpage++; 
            //                    if(idEmail != -1) newIdResearcherWebpage++; 
            //                    if(idInstitutionName != -1) newIdResearcherWebpage++; 
            //                    if(idWebAddress != -1) newIdResearcherWebpage++; 
            //
            //                    List<Object[]> urls_times = new ArrayList<Object[]>();
            //                    while ((nextLine = reader.readNext()) != null) 
            //                    {
            //                        String url = nextLine[newIdResearcherWebpage];
            //
            //                        Object[] url_time = new Object[2];
            //                        url_time[0] = url;
            //                        boolean b = false;
            //                        for(Object[] u : urls_times){
            //                            if(u[0].equals(url_time[0])){
            //                                u[1] = (Integer)u[1] + 1;         
            //                                b = true;
            //                                break;
            //                            }
            //                        }
            //
            //                        if(!b){
            //                            url_time[1] = new Integer(1);
            //                            urls_times.add(url_time);
            //                        }
            //                    }            
            //
            //                    reader.close();                    

            //                try {
            //                    reader = new CSVReader(new FileReader(output_file), CSV_SEPARATOR);
            //                } catch (FileNotFoundException ex) {
            //                    Logger.getRootLogger().error("Error reading " + input_file.getName() + " - " + ex.toString());
            //                }
            //
            //                nextLine = reader.readNext();
            //                try {
            //                    for(int i = 0; i < nextLine.length; i++)
            //                        nextLine[i] = "\"" + nextLine[i] + "\"";
            //                    FileUtils.write(output_file, StringUtil.join(Arrays.asList(nextLine), ";") + "\r\n", "UTF-8", false);
            //                } catch (IOException ex) {
            //                    Logger.getLogger("root").error(ex.toString());
            //                }
            //                
            //                while ((nextLine = reader.readNext()) != null) 
            //                {
            //                    String url = nextLine[newIdResearcherWebpage];
            //                    boolean b = false;
            //                    for(Object[] u : urls_times){
            //                        if(u[0].equals(url) && ((Integer)u[1] == 1)){                                
            //                            b = true;
            //                            break;
            //                        }
            //                    }
            //                    
            //                    if(b){
            //                        try {
            //                            for(int i = 0; i < nextLine.length; i++)
            //                                nextLine[i] = "\"" + nextLine[i] + "\"";
            //                            FileUtils.write(output_file, StringUtil.join(Arrays.asList(nextLine), ";") + "\r\n", "UTF-8", true);
            //                        } catch (IOException ex) {
            //                            Logger.getLogger("root").error(ex.toString());
            //                        }
            //                    }
            //                }
            //                
            //                 reader.close();  

        } catch (Exception ex) {
            String error_msg = "Error extracting cv files from extractor " + input_file.getName();
            Logger.getRootLogger().error(error_msg + " - " + ex.toString());
            if (error_sw != null)
                error_sw.append(error_msg + "\r\n");
            return;
        }
    }
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField)
        throws IOException {
    ModelFormField modelFormField = displayField.getModelFormField();
    ModelForm modelForm = modelFormField.getModelForm();
    String idName = modelFormField.getIdName();
    if (UtilValidate.isNotEmpty(idName)
            && ("list".equals(modelForm.getType()) || "multi".equals(modelForm.getType()))) {
        idName += "_" + modelForm.getRowCount();
    }//from   ww w .  jav  a 2s.c  o  m
    String description = displayField.getDescription(context);
    String type = displayField.getType();
    String imageLocation = displayField.getImageLocation(context);
    Integer size = Integer.valueOf("0");
    String title = "";

    if (UtilValidate.isNotEmpty(displayField.getSize())) {
        try {
            size = Integer.parseInt(displayField.getSize());
        } catch (NumberFormatException nfe) {
            Debug.logError(nfe,
                    "Error reading size of a field fieldName=" + displayField.getModelFormField().getFieldName()
                            + " FormName= " + displayField.getModelFormField().getModelForm().getName(),
                    module);
        }
    }

    ModelFormField.InPlaceEditor inPlaceEditor = displayField.getInPlaceEditor();
    boolean ajaxEnabled = inPlaceEditor != null && this.javaScriptEnabled;
    if (UtilValidate.isNotEmpty(description) && size > 0 && description.length() > size) {
        title = description;
        description = description.substring(0, size - 8) + "..."
                + description.substring(description.length() - 5);
    }

    StringWriter sr = new StringWriter();
    sr.append("<@renderDisplayField ");
    sr.append("type=\"");
    sr.append(type);
    sr.append("\" imageLocation=\"");
    sr.append(imageLocation);
    sr.append("\" idName=\"");
    sr.append(idName);
    sr.append("\" description=\"");
    sr.append(FreeMarkerWorker.encodeDoubleQuotes(description));
    sr.append("\" title=\"");
    sr.append(title);
    sr.append("\" class=\"");
    sr.append(modelFormField.getWidgetStyle());
    sr.append("\" alert=\"");
    sr.append(modelFormField.shouldBeRed(context) ? "true" : "false");

    if (ajaxEnabled) {
        String url = inPlaceEditor.getUrl(context);
        String extraParameter = "{";
        Map<String, Object> fieldMap = inPlaceEditor.getFieldMap(context);
        if (fieldMap != null) {
            Set<Entry<String, Object>> fieldSet = fieldMap.entrySet();
            Iterator<Entry<String, Object>> fieldIterator = fieldSet.iterator();
            int count = 0;
            while (fieldIterator.hasNext()) {
                count++;
                Entry<String, Object> field = fieldIterator.next();
                extraParameter += field.getKey() + ":'" + (String) field.getValue() + "'";
                if (count < fieldSet.size()) {
                    extraParameter += ',';
                }
            }

        }
        extraParameter += "}";
        sr.append("\" inPlaceEditorUrl=\"");
        sr.append(url);
        sr.append("\" inPlaceEditorParams=\"");
        StringWriter inPlaceEditorParams = new StringWriter();
        inPlaceEditorParams.append("{name: '");
        if (UtilValidate.isNotEmpty(inPlaceEditor.getParamName())) {
            inPlaceEditorParams.append(inPlaceEditor.getParamName());
        } else {
            inPlaceEditorParams.append(modelFormField.getFieldName());
        }
        inPlaceEditorParams.append("'");
        inPlaceEditorParams.append(", method: 'POST'");
        inPlaceEditorParams.append(", submitdata: " + extraParameter);
        inPlaceEditorParams.append(", type: 'textarea'");
        inPlaceEditorParams.append(", select: 'true'");
        inPlaceEditorParams.append(
                ", onreset: function(){jQuery('#cc_" + idName + "').css('background-color', 'transparent');}");

        if (UtilValidate.isNotEmpty(inPlaceEditor.getCancelText())) {
            inPlaceEditorParams.append(", cancel: '" + inPlaceEditor.getCancelText() + "'");
        } else {
            inPlaceEditorParams.append(", cancel: 'Cancel'");
        }
        if (UtilValidate.isNotEmpty(inPlaceEditor.getClickToEditText())) {
            inPlaceEditorParams.append(", tooltip: '" + inPlaceEditor.getClickToEditText() + "'");
        }
        if (UtilValidate.isNotEmpty(inPlaceEditor.getFormClassName())) {
            inPlaceEditorParams.append(", cssclass: '" + inPlaceEditor.getFormClassName() + "'");
        } else {
            inPlaceEditorParams.append(", cssclass: 'inplaceeditor-form'");
        }
        if (UtilValidate.isNotEmpty(inPlaceEditor.getLoadingText())) {
            inPlaceEditorParams.append(", indicator: '" + inPlaceEditor.getLoadingText() + "'");
        }
        if (UtilValidate.isNotEmpty(inPlaceEditor.getOkControl())) {
            inPlaceEditorParams.append(", submit: ");
            if (!"false".equals(inPlaceEditor.getOkControl())) {
                inPlaceEditorParams.append("'");
            }
            inPlaceEditorParams.append(inPlaceEditor.getOkControl());
            if (!"false".equals(inPlaceEditor.getOkControl())) {
                inPlaceEditorParams.append("'");
            }
        } else {
            inPlaceEditorParams.append(", submit: 'OK'");
        }
        if (UtilValidate.isNotEmpty(inPlaceEditor.getRows())) {
            inPlaceEditorParams.append(", rows: '" + inPlaceEditor.getRows() + "'");
        }
        if (UtilValidate.isNotEmpty(inPlaceEditor.getCols())) {
            inPlaceEditorParams.append(", cols: '" + inPlaceEditor.getCols() + "'");
        }
        inPlaceEditorParams.append("}");
        sr.append(inPlaceEditorParams.toString());
    }

    sr.append("\" />");
    executeMacro(writer, sr.toString());
    if (displayField instanceof DisplayEntityField) {
        makeHyperlinkString(writer, ((DisplayEntityField) displayField).getSubHyperlink(), context);
    }
    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField)
        throws IOException {
    ModelFormField modelFormField = dateFindField.getModelFormField();

    Locale locale = (Locale) context.get("locale");
    String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
    String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
    String opSameDay = UtilProperties.getMessage("conditional", "same_day", locale);
    String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional", "greater_than_from_day_start",
            locale);//from   w ww  .j av  a 2  s .c  om
    String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
    String opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale);
    String opUpThruDay = UtilProperties.getMessage("conditional", "up_thru_day", locale);
    String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);

    Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
    if (uiLabelMap == null) {
        Debug.logWarning("Could not find uiLabelMap in context", module);
    }
    String localizedInputTitle = "", localizedIconTitle = "";

    String className = "";
    String alert = "false";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }
    }
    String name = modelFormField.getParameterName(context);

    // the default values for a timestamp
    int size = 25;
    int maxlength = 30;
    String dateType = dateFindField.getType();
    if ("date".equals(dateType)) {
        size = maxlength = 10;
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatDate");
        }
    } else if ("time".equals(dateFindField.getType())) {
        size = maxlength = 8;
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatTime");
        }
    } else {
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatDateTime");
        }
    }

    String value = modelFormField.getEntry(context, dateFindField.getDefaultValue(context));
    if (value == null) {
        value = "";
    }

    // search for a localized label for the icon
    if (uiLabelMap != null) {
        localizedIconTitle = uiLabelMap.get("CommonViewCalendar");
    }
    String formName = "";
    String defaultDateTimeString = "";
    StringBuilder imgSrc = new StringBuilder();
    // add calendar pop-up button and seed data IF this is not a "time" type date-find
    if (!"time".equals(dateFindField.getType())) {
        formName = modelFormField.getModelForm().getCurrentFormName(context);
        defaultDateTimeString = UtilHttp.encodeBlanks(
                modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context)));
        this.appendContentUrl(imgSrc, "/images/cal.gif");
    }

    String defaultOptionFrom = dateFindField.getDefaultOptionFrom(context);
    String defaultOptionThru = dateFindField.getDefaultOptionThru(context);
    String value2 = modelFormField.getEntry(context);
    if (value2 == null) {
        value2 = "";
    }
    if (context.containsKey("parameters")) {
        Map<String, Object> parameters = (Map<String, Object>) context.get("parameters");
        if (parameters.containsKey(name + "_fld0_value")) {
            value = (String) parameters.get(name + "_fld0_value");
        }
        if (parameters.containsKey(name + "_fld1_value")) {
            value2 = (String) parameters.get(name + "_fld1_value");
        }
    }
    String titleStyle = "";
    if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
        titleStyle = modelFormField.getTitleStyle();
    }

    StringWriter sr = new StringWriter();
    sr.append("<@renderDateFindField ");
    sr.append(" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" localizedInputTitle=\"");
    sr.append(localizedInputTitle);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" value2=\"");
    sr.append(value2);
    sr.append("\" size=\"");
    sr.append(Integer.toString(size));
    sr.append("\" maxlength=\"");
    sr.append(Integer.toString(maxlength));
    sr.append("\" dateType=\"");
    sr.append(dateType);
    sr.append("\" formName=\"");
    sr.append(formName);
    sr.append("\" defaultDateTimeString=\"");
    sr.append(defaultDateTimeString);
    sr.append("\" imgSrc=\"");
    sr.append(imgSrc.toString());
    sr.append("\" localizedIconTitle=\"");
    sr.append(localizedIconTitle);
    sr.append("\" titleStyle=\"");
    sr.append(titleStyle);
    sr.append("\" defaultOptionFrom=\"");
    sr.append(defaultOptionFrom);
    sr.append("\" defaultOptionThru=\"");
    sr.append(defaultOptionThru);
    sr.append("\" opEquals=\"");
    sr.append(opEquals);
    sr.append("\" opSameDay=\"");
    sr.append(opSameDay);
    sr.append("\" opGreaterThanFromDayStart=\"");
    sr.append(opGreaterThanFromDayStart);
    sr.append("\" opGreaterThan=\"");
    sr.append(opGreaterThan);
    sr.append("\" opGreaterThan=\"");
    sr.append(opGreaterThan);
    sr.append("\" opLessThan=\"");
    sr.append(opLessThan);
    sr.append("\" opUpToDay=\"");
    sr.append(opUpToDay);
    sr.append("\" opUpThruDay=\"");
    sr.append(opUpThruDay);
    sr.append("\" opIsEmpty=\"");
    sr.append(opIsEmpty);
    sr.append("\" />");
    executeMacro(writer, sr.toString());

    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderLookupField(Appendable writer, Map<String, Object> context, LookupField lookupField)
        throws IOException {
    ModelFormField modelFormField = lookupField.getModelFormField();
    String lookupFieldFormName = lookupField.getFormName(context);
    String className = "";
    String alert = "false";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }// www  .  ja va  2s .  c  o m
    }

    //check for required field style on single forms
    if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
        String requiredStyle = modelFormField.getRequiredFieldStyle();
        if (UtilValidate.isEmpty(requiredStyle))
            requiredStyle = "required";
        if (UtilValidate.isEmpty(className))
            className = requiredStyle;
        else
            className = requiredStyle + " " + className;
    }

    String name = modelFormField.getParameterName(context);
    String value = modelFormField.getEntry(context, lookupField.getDefaultValue(context));
    if (value == null) {
        value = "";
    }
    String size = Integer.toString(lookupField.getSize());
    Integer maxlength = lookupField.getMaxlength();
    String id = modelFormField.getCurrentContainerId(context);

    List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas();

    //add default ajax auto completer to all lookup fields
    if (UtilValidate.isEmpty(updateAreas) && UtilValidate.isNotEmpty(lookupFieldFormName)) {
        String autoCompleterTarget = null;
        if (lookupFieldFormName.indexOf('?') == -1) {
            autoCompleterTarget = lookupFieldFormName + "?";
        } else {
            autoCompleterTarget = lookupFieldFormName + "&amp;amp;";
        }
        autoCompleterTarget = autoCompleterTarget + "ajaxLookup=Y";
        updateAreas = FastList.newInstance();
        updateAreas.add(new ModelForm.UpdateArea("change", id, autoCompleterTarget));
    }

    boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled;
    String autocomplete = "";
    if (!lookupField.getClientAutocompleteField() || !ajaxEnabled) {
        autocomplete = "off";
    }

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

    // add lookup pop-up button
    String descriptionFieldName = lookupField.getDescriptionFieldName();
    String formName = modelFormField.getParentFormName();
    if (UtilValidate.isEmpty(formName)) {
        formName = modelFormField.getModelForm().getCurrentFormName(context);
    }
    StringBuilder targetParameterIter = new StringBuilder();
    StringBuilder imgSrc = new StringBuilder();
    // FIXME: refactor using the StringUtils methods
    List<String> targetParameterList = lookupField.getTargetParameterList();
    targetParameterIter.append("[");
    for (String targetParameter : targetParameterList) {
        if (targetParameterIter.length() > 1) {
            targetParameterIter.append(",");
        }
        targetParameterIter.append("'");
        targetParameterIter.append(targetParameter);
        targetParameterIter.append("'");
    }
    targetParameterIter.append("]");
    this.appendContentUrl(imgSrc, "/images/fieldlookup.gif");

    String ajaxUrl = "";

    if (ajaxEnabled) {
        ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
    }

    String lookupPresentation = lookupField.getLookupPresentation();
    if (UtilValidate.isEmpty(lookupPresentation)) {
        lookupPresentation = "";
    }

    String lookupHeight = lookupField.getLookupHeight();
    if (UtilValidate.isEmpty(lookupHeight)) {
        lookupHeight = "";
    }

    String lookupWidth = lookupField.getLookupWidth();
    if (UtilValidate.isEmpty(lookupWidth)) {
        lookupWidth = "";
    }

    String lookupPosition = lookupField.getLookupPosition();
    if (UtilValidate.isEmpty(lookupPosition)) {
        lookupPosition = "";
    }

    String fadeBackground = lookupField.getFadeBackground();
    if (UtilValidate.isEmpty(fadeBackground)) {
        fadeBackground = "false";
    }
    Boolean isInitiallyCollapsed = lookupField.getInitiallyCollapsed();

    String clearText = "";
    Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
    if (uiLabelMap != null) {
        clearText = (String) uiLabelMap.get("CommonClear");
    } else {
        Debug.logWarning("Could not find uiLabelMap in context", module);
    }

    boolean showDescription = "Y"
            .equals(UtilProperties.getPropertyValue("widget", "widget.lookup.showDescription", "N"));

    // lastViewName, used by lookup to remember the real last view name
    String lastViewName = request.getParameter("_LAST_VIEW_NAME_"); // Try to get it from parameters firstly
    if (UtilValidate.isEmpty(lastViewName)) { // get from session
        lastViewName = (String) request.getSession().getAttribute("_LAST_VIEW_NAME_");
    }
    if (UtilValidate.isEmpty(lastViewName)) {
        lastViewName = "";
    }
    StringWriter sr = new StringWriter();
    sr.append("<@renderLookupField ");
    sr.append(" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" size=\"");
    sr.append(size);
    sr.append("\" maxlength=\"");
    sr.append((maxlength != null ? Integer.toString(maxlength) : ""));
    sr.append("\" id=\"");
    sr.append(id);
    sr.append("\" event=\"");
    if (event != null) {
        sr.append(event);
    }
    sr.append("\" action=\"");
    if (action != null) {
        sr.append(action);
    }
    sr.append("\" readonly=");
    sr.append(Boolean.toString(readonly));

    sr.append(" autocomplete=\"");
    sr.append(autocomplete);
    sr.append("\" descriptionFieldName=\"");
    sr.append(descriptionFieldName);
    sr.append("\" formName=\"");
    sr.append(formName);
    sr.append("\" fieldFormName=\"");
    sr.append(lookupFieldFormName);
    sr.append("\" targetParameterIter=");
    sr.append(targetParameterIter.toString());
    sr.append(" imgSrc=\"");
    sr.append(imgSrc.toString());
    sr.append("\" ajaxUrl=\"");
    sr.append(ajaxUrl);
    sr.append("\" ajaxEnabled=");
    sr.append(Boolean.toString(ajaxEnabled));
    sr.append(" presentation=\"");
    sr.append(lookupPresentation);
    sr.append("\" height=\"");
    sr.append(lookupHeight);
    sr.append("\" width=\"");
    sr.append(lookupWidth);
    sr.append("\" position=\"");
    sr.append(lookupPosition);
    sr.append("\" fadeBackground=\"");
    sr.append(fadeBackground);
    sr.append("\" clearText=\"");
    sr.append(clearText);
    sr.append("\" showDescription=\"");
    sr.append(Boolean.toString(showDescription));
    sr.append("\" initiallyCollapsed=\"");
    sr.append(Boolean.toString(isInitiallyCollapsed));
    sr.append("\" lastViewName=\"");
    sr.append(lastViewName);
    sr.append("\" />");
    executeMacro(writer, sr.toString());

    this.addAsterisks(writer, context, modelFormField);

    this.makeHyperlinkString(writer, lookupField.getSubHyperlink(), context);
    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderDateTimeField(Appendable writer, Map<String, Object> context, DateTimeField dateTimeField)
        throws IOException {
    ModelFormField modelFormField = dateTimeField.getModelFormField();
    String paramName = modelFormField.getParameterName(context);
    String defaultDateTimeString = dateTimeField.getDefaultDateTimeString(context);
    String className = "";
    String alert = "false";
    String name = "";
    String formattedMask = "";
    String event = modelFormField.getEvent();
    String action = modelFormField.getAction(context);
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }/*from w w  w  . ja va2s. co m*/
    }
    boolean useTimeDropDown = "time-dropdown".equals(dateTimeField.getInputMethod());
    String stepString = dateTimeField.getStep();
    int step = 1;
    StringBuilder timeValues = new StringBuilder();
    if (useTimeDropDown && UtilValidate.isNotEmpty(step)) {
        try {
            step = Integer.valueOf(stepString).intValue();
        } catch (IllegalArgumentException e) {
            Debug.logWarning("Inavalid value for step property for field[" + paramName
                    + "] with input-method=\"time-dropdown\" " + " Found Value [" + stepString + "]  "
                    + e.getMessage(), module);
        }
        timeValues.append("[");
        for (int i = 0; i <= 59;) {
            if (i != 0) {
                timeValues.append(", ");
            }
            timeValues.append(i);
            i += step;
        }
        timeValues.append("]");
    }
    Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
    if (uiLabelMap == null) {
        Debug.logWarning("Could not find uiLabelMap in context", module);
    }
    String localizedInputTitle = "", localizedIconTitle = "";

    // whether the date field is short form, yyyy-mm-dd
    boolean shortDateInput = ("date".equals(dateTimeField.getType()) || useTimeDropDown ? true : false);

    if (useTimeDropDown) {
        name = UtilHttp.makeCompositeParam(paramName, "date");
    } else {
        name = paramName;
    }

    // the default values for a timestamp
    int size = 25;
    int maxlength = 30;

    if (shortDateInput) {
        size = maxlength = 10;
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatDate");
        }
    } else if ("time".equals(dateTimeField.getType())) {
        size = maxlength = 8;
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatTime");
        }
    } else {
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatDateTime");
        }
    }

    String contextValue = null;
    // If time-dropdown deactivate encodingOutput for found hour and minutes
    boolean memEncodeOutput = modelFormField.getEncodeOutput();
    if (useTimeDropDown)
        // FIXME: This is not thread-safe! Never modify a model's state!
        modelFormField.setEncodeOutput(false);
    // FIXME: modelFormField.getEntry ignores shortDateInput when converting Date objects to Strings.
    // Object type conversion should be done by the renderer, not by the model.
    contextValue = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context));
    if (useTimeDropDown)
        modelFormField.setEncodeOutput(memEncodeOutput);

    String value = contextValue;
    if (UtilValidate.isNotEmpty(value)) {
        if (value.length() > maxlength) {
            value = value.substring(0, maxlength);
        }
    }
    String id = modelFormField.getCurrentContainerId(context);
    String formName = modelFormField.getModelForm().getCurrentFormName(context);
    String timeDropdown = dateTimeField.getInputMethod();
    String timeDropdownParamName = "";
    String classString = "";
    boolean isTwelveHour = false;
    String timeHourName = "";
    int hour2 = 0, hour1 = 0, minutes = 0;
    String timeMinutesName = "";
    String amSelected = "", pmSelected = "", ampmName = "";
    String compositeType = "";
    // search for a localized label for the icon
    if (uiLabelMap != null) {
        localizedIconTitle = uiLabelMap.get("CommonViewCalendar");
    }

    if (!"time".equals(dateTimeField.getType())) {
        String tempParamName;
        if (useTimeDropDown) {
            tempParamName = UtilHttp.makeCompositeParam(paramName, "date");
        } else {
            tempParamName = paramName;
        }
        timeDropdownParamName = tempParamName;
        defaultDateTimeString = UtilHttp.encodeBlanks(modelFormField.getEntry(context, defaultDateTimeString));
    }

    // if we have an input method of time-dropdown, then render two
    // dropdowns
    if (useTimeDropDown) {
        className = modelFormField.getWidgetStyle();
        classString = (className != null ? className : "");
        isTwelveHour = "12".equals(dateTimeField.getClock());

        // set the Calendar to the default time of the form or now()
        Calendar cal = null;
        try {
            Timestamp defaultTimestamp = Timestamp.valueOf(contextValue);
            cal = Calendar.getInstance();
            cal.setTime(defaultTimestamp);
        } catch (IllegalArgumentException e) {
            Debug.logWarning("Form widget field [" + paramName
                    + "] with input-method=\"time-dropdown\" was not able to understand the default time ["
                    + defaultDateTimeString + "]. The parsing error was: " + e.getMessage(), module);
        }

        timeHourName = UtilHttp.makeCompositeParam(paramName, "hour");
        if (cal != null) {
            int hour = cal.get(Calendar.HOUR_OF_DAY);
            hour2 = hour;
            if (hour == 0) {
                hour = 12;
            }
            if (hour > 12) {
                hour -= 12;
            }
            hour1 = hour;
            minutes = cal.get(Calendar.MINUTE);
        }
        timeMinutesName = UtilHttp.makeCompositeParam(paramName, "minutes");
        compositeType = UtilHttp.makeCompositeParam(paramName, "compositeType");
        // if 12 hour clock, write the AM/PM selector
        if (isTwelveHour) {
            amSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.AM) ? "selected" : "");
            pmSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.PM) ? "selected" : "");
            ampmName = UtilHttp.makeCompositeParam(paramName, "ampm");
        }
    }

    //check for required field style on single forms
    if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
        String requiredStyle = modelFormField.getRequiredFieldStyle();
        if (UtilValidate.isEmpty(requiredStyle))
            requiredStyle = "required";
        if (UtilValidate.isEmpty(className))
            className = requiredStyle;
        else
            className = requiredStyle + " " + className;
    }

    String mask = dateTimeField.getMask();
    if ("Y".equals(mask)) {
        if ("date".equals(dateTimeField.getType())) {
            formattedMask = "9999-99-99";
        } else if ("time".equals(dateTimeField.getType())) {
            formattedMask = "99:99:99";
        } else if ("timestamp".equals(dateTimeField.getType())) {
            formattedMask = "9999-99-99 99:99:99";
        }
    }
    StringWriter sr = new StringWriter();
    sr.append("<@renderDateTimeField ");
    sr.append("name=\"");
    sr.append(name);
    sr.append("\" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" title=\"");
    sr.append(localizedInputTitle);
    sr.append("\" size=\"");
    sr.append(Integer.toString(size));
    sr.append("\" maxlength=\"");
    sr.append(Integer.toString(maxlength));
    sr.append("\" step=\"");
    sr.append(Integer.toString(step));
    sr.append("\" timeValues=\"");
    sr.append(timeValues.toString());
    sr.append("\" id=\"");
    sr.append(id);
    sr.append("\" event=\"");
    sr.append(event);
    sr.append("\" action=\"");
    sr.append(action);
    sr.append("\" dateType=\"");
    sr.append(dateTimeField.getType());
    sr.append("\" shortDateInput=");
    sr.append(Boolean.toString(shortDateInput));
    sr.append(" timeDropdownParamName=\"");
    sr.append(timeDropdownParamName);
    sr.append("\" defaultDateTimeString=\"");
    sr.append(defaultDateTimeString);
    sr.append("\" localizedIconTitle=\"");
    sr.append(localizedIconTitle);
    sr.append("\" timeDropdown=\"");
    sr.append(timeDropdown);
    sr.append("\" timeHourName=\"");
    sr.append(timeHourName);
    sr.append("\" classString=\"");
    sr.append(classString);
    sr.append("\" hour1=");
    sr.append(Integer.toString(hour1));
    sr.append(" hour2=");
    sr.append(Integer.toString(hour2));
    sr.append(" timeMinutesName=\"");
    sr.append(timeMinutesName);
    sr.append("\" minutes=");
    sr.append(Integer.toString(minutes));
    sr.append(" isTwelveHour=");
    sr.append(Boolean.toString(isTwelveHour));
    sr.append(" ampmName=\"");
    sr.append(ampmName);
    sr.append("\" amSelected=\"");
    sr.append(amSelected);
    sr.append("\" pmSelected=\"");
    sr.append(pmSelected);
    sr.append("\" compositeType=\"");
    sr.append(compositeType);
    sr.append("\" formName=\"");
    sr.append(formName);
    sr.append("\" mask=\"");
    sr.append(formattedMask);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
    this.addAsterisks(writer, context, modelFormField);
    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField)
        throws IOException {
    ModelFormField modelFormField = dropDownField.getModelFormField();
    ModelForm modelForm = modelFormField.getModelForm();
    String currentValue = modelFormField.getEntry(context);
    List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context,
            WidgetWorker.getDelegator(context));
    ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete();
    String event = modelFormField.getEvent();
    String action = modelFormField.getAction(context);
    Integer textSize = Integer.valueOf(0);
    if (UtilValidate.isNotEmpty(dropDownField.getTextSize())) {
        try {//from   ww  w . j  a  v  a2s . co  m
            textSize = Integer.parseInt(dropDownField.getTextSize());
        } catch (NumberFormatException nfe) {
            Debug.logError(nfe,
                    "Error reading size of a field fieldName="
                            + dropDownField.getModelFormField().getFieldName() + " FormName= "
                            + dropDownField.getModelFormField().getModelForm().getName(),
                    module);
        }
        if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) {
            currentValue = currentValue.substring(0, textSize - 8) + "..."
                    + currentValue.substring(currentValue.length() - 5);
        }
    }
    boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled;
    String className = "";
    String alert = "false";
    String name = modelFormField.getParameterName(context);
    String id = modelFormField.getCurrentContainerId(context);
    String multiple = dropDownField.isAllowMultiple() ? "multiple" : "";
    String otherFieldName = "";
    String formName = modelForm.getName();
    String size = dropDownField.getSize();
    String dDFCurrent = dropDownField.getCurrent();
    String firstInList = "";
    String explicitDescription = "";
    String allowEmpty = "";
    StringBuilder options = new StringBuilder();
    StringBuilder ajaxOptions = new StringBuilder();
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }
    }

    //check for required field style on single forms
    if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
        String requiredStyle = modelFormField.getRequiredFieldStyle();
        if (UtilValidate.isEmpty(requiredStyle))
            requiredStyle = "required";
        if (UtilValidate.isEmpty(className))
            className = requiredStyle;
        else
            className = requiredStyle + " " + className;
    }

    String currentDescription = null;
    if (UtilValidate.isNotEmpty(currentValue)) {
        for (ModelFormField.OptionValue optionValue : allOptionValues) {
            if (optionValue.getKey().equals(currentValue)) {
                currentDescription = optionValue.getDescription();
                break;
            }
        }
    }

    int otherFieldSize = dropDownField.getOtherFieldSize();
    if (otherFieldSize > 0) {
        otherFieldName = dropDownField.getParameterNameOther(context);
    }
    // if the current value should go first, stick it in
    if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) {
        firstInList = "first-in-list";
    }
    explicitDescription = (currentDescription != null ? currentDescription
            : dropDownField.getCurrentDescription(context));
    if (UtilValidate.isEmpty(explicitDescription)) {
        explicitDescription = (ModelFormField.FieldInfoWithOptions.getDescriptionForOptionKey(currentValue,
                allOptionValues));
    }

    if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription)
            && explicitDescription.length() > textSize) {
        explicitDescription = explicitDescription.substring(0, textSize - 8) + "..."
                + explicitDescription.substring(explicitDescription.length() - 5);
    }
    explicitDescription = encode(explicitDescription, modelFormField, context);
    // if allow empty is true, add an empty option
    if (dropDownField.isAllowEmpty()) {
        allowEmpty = "Y";
    }

    List<String> currentValueList = null;
    if (UtilValidate.isNotEmpty(currentValue) && dropDownField.isAllowMultiple()) {
        // If currentValue is Array, it will start with [
        if (currentValue.startsWith("[")) {
            currentValueList = StringUtil.toList(currentValue);
        } else {
            currentValueList = UtilMisc.toList(currentValue);
        }
    }
    options.append("[");
    Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator();
    int count = 0;
    while (optionValueIter.hasNext()) {
        ModelFormField.OptionValue optionValue = optionValueIter.next();
        if (options.length() > 1) {
            options.append(",");
        }
        options.append("{'key':'");
        String key = encode(optionValue.getKey(), modelFormField, context);
        options.append(key);
        options.append("'");
        options.append(",'description':'");
        String description = optionValue.getDescription();
        if (textSize > 0 && description.length() > textSize) {
            description = description.substring(0, textSize - 8) + "..."
                    + description.substring(description.length() - 5);
        }
        options.append(encode(description, modelFormField, context));

        if (UtilValidate.isNotEmpty(currentValueList)) {
            options.append("'");
            options.append(",'selected':'");
            if (currentValueList.contains(optionValue.getKey())) {
                options.append("selected");
            } else {
                options.append("");
            }
        }

        options.append("'}");
        if (ajaxEnabled) {
            count++;
            ajaxOptions.append(optionValue.getKey()).append(": ");
            ajaxOptions.append(" '").append(optionValue.getDescription()).append("'");
            if (count != allOptionValues.size()) {
                ajaxOptions.append(", ");
            }
        }
    }
    options.append("]");
    String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context);
    String otherValue = "", fieldName = "";
    // Adapted from work by Yucca Korpela
    // http://www.cs.tut.fi/~jkorpela/forms/combo.html
    if (otherFieldSize > 0) {
        fieldName = modelFormField.getParameterName(context);
        Map<String, ? extends Object> dataMap = modelFormField.getMap(context);
        if (dataMap == null) {
            dataMap = context;
        }
        Object otherValueObj = dataMap.get(otherFieldName);
        otherValue = (otherValueObj == null) ? "" : otherValueObj.toString();
    }
    String frequency = "";
    String minChars = "";
    String choices = "";
    String autoSelect = "";
    String partialSearch = "";
    String partialChars = "";
    String ignoreCase = "";
    String fullSearch = "";
    if (ajaxEnabled) {
        frequency = autoComplete.getFrequency();
        minChars = autoComplete.getMinChars();
        choices = autoComplete.getChoices();
        autoSelect = autoComplete.getAutoSelect();
        partialSearch = autoComplete.getPartialSearch();
        partialChars = autoComplete.getPartialChars();
        ignoreCase = autoComplete.getIgnoreCase();
        fullSearch = autoComplete.getFullSearch();
    }

    StringWriter sr = new StringWriter();
    sr.append("<@renderDropDownField ");
    sr.append("name=\"");
    sr.append(name);
    sr.append("\" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" id=\"");
    sr.append(id);
    sr.append("\" multiple=\"");
    sr.append(multiple);
    sr.append("\" formName=\"");
    sr.append(formName);
    sr.append("\" otherFieldName=\"");
    sr.append(otherFieldName);
    sr.append("\" event=\"");
    if (event != null) {
        sr.append(event);
    }
    sr.append("\" action=\"");
    if (action != null) {
        sr.append(action);
    }
    sr.append("\" size=\"");
    sr.append(size);
    sr.append("\" firstInList=\"");
    sr.append(firstInList);
    sr.append("\" currentValue=\"");
    sr.append(currentValue);
    sr.append("\" explicitDescription=\"");
    sr.append(explicitDescription);
    sr.append("\" allowEmpty=\"");
    sr.append(allowEmpty);
    sr.append("\" options=");
    sr.append(options.toString());
    sr.append(" fieldName=\"");
    sr.append(fieldName);
    sr.append("\" otherFieldName=\"");
    sr.append(otherFieldName);
    sr.append("\" otherValue=\"");
    sr.append(otherValue);
    sr.append("\" otherFieldSize=");
    sr.append(Integer.toString(otherFieldSize));
    sr.append(" dDFCurrent=\"");
    sr.append(dDFCurrent);
    sr.append("\" ajaxEnabled=");
    sr.append(Boolean.toString(ajaxEnabled));
    sr.append(" noCurrentSelectedKey=\"");
    sr.append(noCurrentSelectedKey);
    sr.append("\" ajaxOptions=\"");
    sr.append(ajaxOptions.toString());
    sr.append("\" frequency=\"");
    sr.append(frequency);
    sr.append("\" minChars=\"");
    sr.append(minChars);
    sr.append("\" choices=\"");
    sr.append(choices);
    sr.append("\" autoSelect=\"");
    sr.append(autoSelect);
    sr.append("\" partialSearch=\"");
    sr.append(partialSearch);
    sr.append("\" partialChars=\"");
    sr.append(partialChars);
    sr.append("\" ignoreCase=\"");
    sr.append(ignoreCase);
    sr.append("\" fullSearch=\"");
    sr.append(fullSearch);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
    ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink();
    if (subHyperlink != null && subHyperlink.shouldUse(context)) {
        makeHyperlinkString(writer, subHyperlink, context);
    }
    this.appendTooltip(writer, context, modelFormField);
}