r973 - in trunk/wikitty-struts/src/main/java: org/nuiton/wikitty/struts/component template/xhtml
Author: mfortun Date: 2011-06-24 15:41:11 +0200 (Fri, 24 Jun 2011) New Revision: 973 Url: http://nuiton.org/repositories/revision/wikitty/973 Log: * add ordering * complete model for field tag Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/ExtensionFieldStrutsBean.java trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/FieldSpecialisation.java trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldHandler.java trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldTagBean.java trunk/wikitty-struts/src/main/java/template/xhtml/wikitty-close.ftl Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/ExtensionFieldStrutsBean.java =================================================================== --- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/ExtensionFieldStrutsBean.java 2011-06-24 12:20:56 UTC (rev 972) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/ExtensionFieldStrutsBean.java 2011-06-24 13:41:11 UTC (rev 973) @@ -6,8 +6,14 @@ protected String name; protected String type; protected Object value; - - + protected String label; + + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } public String getName() { return name; } @@ -31,13 +37,8 @@ super(); } - public ExtensionFieldStrutsBean(String name, String type, Object value) { - super(); - this.name = name; - this.type = type; - this.value = value; - } + Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/FieldSpecialisation.java =================================================================== --- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/FieldSpecialisation.java 2011-06-24 12:20:56 UTC (rev 972) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/FieldSpecialisation.java 2011-06-24 13:41:11 UTC (rev 973) @@ -6,6 +6,7 @@ protected String type; protected String criteria; protected String subtype; + protected String label; public String getName() { return name; @@ -39,4 +40,12 @@ this.subtype = subtype; } + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + } Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldHandler.java =================================================================== --- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldHandler.java 2011-06-24 12:20:56 UTC (rev 972) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldHandler.java 2011-06-24 13:41:11 UTC (rev 973) @@ -1,5 +1,6 @@ package org.nuiton.wikitty.struts.component; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -17,13 +18,14 @@ protected Wikitty wikitty; protected WikittyProxy proxy; - protected String include; - protected String exclude; - protected String order; + protected String include = ""; + protected String exclude = ""; + protected String order = ""; protected List<FieldSpecialisation> field; public WikittyFieldHandler() { super(); + field = new LinkedList<FieldSpecialisation>(); } public Wikitty getWikitty() { @@ -76,12 +78,12 @@ } public void specialiseField(FieldSpecialisation fieldSpe) { - + field.add(fieldSpe); } - public List<ExtensionFieldStrutsBean> getWikittyField() { + public Collection<ExtensionFieldStrutsBean> getWikittyField() { - List<ExtensionFieldStrutsBean> result = new LinkedList<ExtensionFieldStrutsBean>(); + Map<String, ExtensionFieldStrutsBean> mapField = new HashMap<String, ExtensionFieldStrutsBean>(); /* * if no include defined, by default will select all wikitty field @@ -171,6 +173,7 @@ ExtensionFieldStrutsBean temp = new ExtensionFieldStrutsBean(); temp.setName(extName + "." + fieldName); + temp.setLabel(temp.getName()); temp.setValue(""); switch (fieldType.getType()) { @@ -210,11 +213,33 @@ } } - result.add(temp); + mapField.put(temp.getName(), temp); } } - return result; + String[] fieldOrder = StringUtil.split(order, ","); + + /* + * if an order is define parse order and construct ordering result + * if all the field are not defined in the order juste add the rest + * at the end of the result list. + */ + if (fieldOrder.length != 0) { + + List<ExtensionFieldStrutsBean> orderedResult = new LinkedList<ExtensionFieldStrutsBean>(); + + for (String orderIt : fieldOrder) { + + if (mapField.containsKey(orderIt)) { + orderedResult.add(mapField.remove(orderIt)); + } + + } + orderedResult.addAll(mapField.values()); + return orderedResult; + } + + return mapField.values(); } } Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldTagBean.java =================================================================== --- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldTagBean.java 2011-06-24 12:20:56 UTC (rev 972) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldTagBean.java 2011-06-24 13:41:11 UTC (rev 973) @@ -13,6 +13,7 @@ protected String subtype; protected String criteria; protected String type; + protected String label; public String getSubtype() { return subtype; @@ -66,6 +67,7 @@ spe.setName(name); spe.setSubtype(subtype); spe.setType(type); + spe.setLabel(label); handler.specialiseField(spe); @@ -105,4 +107,12 @@ */ } + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + } Modified: trunk/wikitty-struts/src/main/java/template/xhtml/wikitty-close.ftl =================================================================== --- trunk/wikitty-struts/src/main/java/template/xhtml/wikitty-close.ftl 2011-06-24 12:20:56 UTC (rev 972) +++ trunk/wikitty-struts/src/main/java/template/xhtml/wikitty-close.ftl 2011-06-24 13:41:11 UTC (rev 973) @@ -4,29 +4,29 @@ <#if aKey.type=="file"> <input type="hidden" name="${aKey.name}" value="BINARY" /> -<input type="file" name="File" label ="File"/> +${aKey.label} : <input type="file" name="File" label ="File"/> </#if> + +<#if aKey.type=="hidden"> +<input type="hidden" name="${aKey.name}" value="${aKey.value}" /> +</#if> + + <#if aKey.type=="textarea" > -<textarea id="${aKey.name}" cols="80" rows="20" name="${aKey.name}">${aKey.value}</textarea> +${aKey.label} : <textarea id="${aKey.name}" cols="80" rows="20" name="${aKey.name}">${aKey.value}</textarea> </#if> <#if aKey.type=="textfield" > -<input type="text" name="${aKey.name}" value="${aKey.value}" > +${aKey.label} : <input type="text" name="${aKey.name}" value="${aKey.value}" > </#if> <#if aKey.type=="boolean" > -<input type="checkbox" name="${aKey.name}" value="true" +${aKey.label} : <input type="checkbox" name="${aKey.name}" value="true" <#if aKey.value=="true" > checked='true' </#if> /> </#if> -<#-- -/*<#if parameters.nullable?? > -*<input type="checkbox" name="isNull- ${aKey.name}" -* value="true" " checkedNull "/>(null)" -*</#if>*/ ---> </br> </#list><#t/>
participants (1)
-
mfortun@users.nuiton.org