public void renderPendingFields() throws Exception { WysiwygFormEditor wysiwygFormEditor = WysiwygFormEditor.lookup(); Form form = wysiwygFormEditor.getCurrentForm(); Set<DataHolder> holders = form.getHolders(); renderFragment("outputStart"); for (DataHolder dataHolder : holders) { Set<DataFieldHolder> dataFieldHolders = getUnBindedFields(form, dataHolder); if (dataFieldHolders != null && !dataFieldHolders.isEmpty()) { if (dataHolder.canHaveChildren()) { setAttribute("id", dataHolder.getUniqeId()); setAttribute("type", dataHolder.getTypeCode()); setAttribute("renderColor", dataHolder.getRenderColor()); if (dataHolder.getUniqeId() != null && dataHolder.getUniqeId().equals(wysiwygFormEditor.getLastDataHolderUsedId())) { setAttribute("open", Boolean.TRUE); } else { setAttribute("open", Boolean.FALSE); } String holderName = ""; holderName = dataHolder.getUniqeId(); if (holderName.length() > 20) holderName = holderName.substring(0, 19) + "..."; setAttribute("showHolderName", holderName); renderFragment("outputBinding"); } for (DataFieldHolder dataFieldHolder : dataFieldHolders) { String fieldName = dataFieldHolder.getId(); if (fieldName != null && !form.isFieldBinded(dataHolder, fieldName)) { renderAddField(fieldName, dataFieldHolder, dataHolder); } } if (dataHolder.canHaveChildren()) { renderFragment("outputEndBinding"); } } } renderFragment("outputEnd"); }
public void service( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws FormatterException { try { if (WysiwygFormEditor.EDITION_OPTION_BINDINGS_FIELDS.equals( wysiwygFormEditor.getCurrentEditionOption())) { renderPendingFields(); } else { renderDataHolders(); } } catch (Exception e) { log.error(" DataHoldersFormFormatter rendering error"); } }
public void renderDataHolders() { try { renderFragment("outputStartHeader"); for (DataHolderBuilder builder : dataHolderManager.getHolderBuilders()) { if (builder instanceof RangedDataHolderBuilder) notifyHolderBuilder( (RangedDataHolderBuilder) builder, wysiwygFormEditor.getCurrentEditionContext().getPath()); else notifyHolderBuilder(builder); } renderFragment("outputEndHeader"); renderFragment("outputStart"); Form form = wysiwygFormEditor.getCurrentForm(); Set<DataHolder> holders = form.getHolders(); String existingIds = "\"\""; String existingInputIds = "\"\""; String existingOutputIds = "\"\""; for (DataHolder holder : holders) { if (!StringUtils.isEmpty(holder.getInputId())) existingInputIds += ", \"" + holder.getInputId() + "\" "; if (!StringUtils.isEmpty(holder.getOuputId())) existingOutputIds += ", \"" + holder.getOuputId() + "\" "; if (!StringUtils.isEmpty(holder.getUniqeId())) existingIds += ", \"" + holder.getUniqeId() + "\" "; } setAttribute("existingIds", existingIds); setAttribute("existingInputIds", existingInputIds); setAttribute("existingOutputIds", existingOutputIds); renderFragment("outputFormAddHolderStart"); Map<String, String> colors = dataHolderManager.getHolderColors(); for (Iterator it = colors.keySet().iterator(); it.hasNext(); ) { String color = (String) it.next(); String name = colors.get(color); setAttribute("color", color); setAttribute("name", name); renderFragment("color"); } Map<String, String> builderNames = new HashMap<String, String>(); // Render source types sorted by value. renderFragment("outputFormHolderTypes"); for (DataHolderBuilder builder : dataHolderManager.getHolderBuilders()) { String holderName = builder.getDataHolderName(getLocale()); builderNames.put(builder.getId(), holderName); setAttribute("holderType", builder.getId()); setAttribute("holderName", holderName); renderFragment("outputHolderType"); } renderFragment("outputEndHolderTypes"); renderFragment("outputStartBindings"); int i = 0; for (DataHolder holder : holders) { setAttribute("id", StringUtils.defaultString(holder.getUniqeId())); setAttribute("input_id", StringUtils.defaultString(holder.getInputId())); setAttribute("outId", StringUtils.defaultString(holder.getOuputId())); setAttribute("deleteId", StringUtils.defaultString(holder.getUniqeId())); setAttribute( "type", builderNames.get( StringUtils.defaultIfEmpty(holder.getSupportedType(), holder.getTypeCode()))); setAttribute("renderColor", holder.getRenderColor()); setAttribute("value", holder.getInfo()); setAttribute("rowStyle", i % 2 == 1 ? "skn-even_row" : "skn-odd_row"); i++; renderFragment("outputBindings"); } renderFragment("outputEndBindings"); renderFragment("outputEnd"); } catch (Exception e) { log.error("Error:", e); } }