Author: mfortun Date: 2011-06-24 17:13:20 +0200 (Fri, 24 Jun 2011) New Revision: 975 Url: http://nuiton.org/repositories/revision/wikitty/975 Log: * change wikitty field model * update logic within field specialization 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/org/nuiton/wikitty/struts/tag/WikittyFieldTag.java trunk/wikitty-struts/src/main/tld/wikitty-struts.tld 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 13:51:08 UTC (rev 974) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/ExtensionFieldStrutsBean.java 2011-06-24 15:13:20 UTC (rev 975) @@ -7,6 +7,9 @@ protected String type; protected Object value; protected String label; + + + public String getLabel() { return label; 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 13:51:08 UTC (rev 974) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/FieldSpecialisation.java 2011-06-24 15:13:20 UTC (rev 975) @@ -7,7 +7,26 @@ protected String criteria; protected String subtype; protected String label; + protected String descfields; + protected String fixvalues; + + public String getDescfields() { + return descfields; + } + + public void setDescfields(String descfields) { + this.descfields = descfields; + } + + public String getFixvalues() { + return fixvalues; + } + + public void setFixvalues(String fixvalues) { + this.fixvalues = fixvalues; + } + public String getName() { return name; } 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 13:51:08 UTC (rev 974) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldHandler.java 2011-06-24 15:13:20 UTC (rev 975) @@ -19,10 +19,10 @@ protected String include = ""; protected String exclude = ""; protected String order = ""; - protected List<FieldSpecialisation> field; + protected Map<String,FieldSpecialisation> field; public WikittyFieldHandler() { - field = new LinkedList<FieldSpecialisation>(); + field = new HashMap<String,FieldSpecialisation>(); } public Wikitty getWikitty() { @@ -65,17 +65,18 @@ this.order = order; } - public List<FieldSpecialisation> getField() { + + public Map<String, FieldSpecialisation> getField() { return field; } - public void setField(List<FieldSpecialisation> field) { + public void setField(Map<String, FieldSpecialisation> field) { this.field = field; } public void specialiseField(FieldSpecialisation fieldSpe) { - field.add(fieldSpe); + field.put(fieldSpe.getName(),fieldSpe); } public Collection<ExtensionFieldStrutsBean> getWikittyField() { 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 13:51:08 UTC (rev 974) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/WikittyFieldTagBean.java 2011-06-24 15:13:20 UTC (rev 975) @@ -10,35 +10,11 @@ @StrutsTag(name = "field", tldTagClass = "org.nuiton.wikitty.struts.tag.WikittyFieldTag", description = "Renders an input form", allowDynamicAttributes = false) public class WikittyFieldTagBean extends ClosingUIBean { - protected String subtype; - protected String criteria; - protected String type; - protected String label; + + protected FieldSpecialisation specialize; + + - public String getSubtype() { - return subtype; - } - - public void setSubtype(String subtype) { - this.subtype = subtype; - } - - public String getCriteria() { - return criteria; - } - - public void setCriteria(String criteria) { - this.criteria = criteria; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - public WikittyFieldTagBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); @@ -60,53 +36,19 @@ super.evaluateExtraParams(); WikittyFieldHandler handler = (WikittyFieldHandler) stack.getContext() - .get(WikittyTagBean.WIKITTY_STACK_KEY); - - FieldSpecialisation spe = new FieldSpecialisation(); - spe.setCriteria(criteria); - spe.setName(name); - spe.setSubtype(subtype); - spe.setType(type); - spe.setLabel(label); + .get(WikittyTagBean.WIKITTY_STACK_KEY); + handler.specialiseField(specialize); - handler.specialiseField(spe); - - - /* - * if (validate != null) { addParameter("validate", findValue(validate, - * Boolean.class)); } - * - * if (name == null) { //make the name the same as the id String id = - * (String) getParameters().get("id"); if (StringUtils.isNotEmpty(id)) { - * addParameter("name", id); } } - * - * if (onsubmit != null) { addParameter("onsubmit", - * findString(onsubmit)); } - * - * if (onreset != null) { addParameter("onreset", findString(onreset)); - * } - * - * if (target != null) { addParameter("target", findString(target)); } - * - * if (enctype != null) { addParameter("enctype", findString(enctype)); - * } - * - * if (method != null) { addParameter("method", findString(method)); } - * - * if (acceptcharset != null) { addParameter("acceptcharset", - * findString(acceptcharset)); } - * - * // keep a collection of the tag names for anything special the - * templates might want to do (such as pure client // side validation) - * if (!parameters.containsKey("tagNames")) { // we have this if check - * so we don't do this twice (on open and close of the template) - * addParameter("tagNames", new ArrayList()); } - * - * if (focusElement != null) { addParameter("focusElement", - * findString(focusElement)); } - */ } + public FieldSpecialisation getSpecialize() { + return specialize; + } + + public void setSpecialize(FieldSpecialisation specialize) { + this.specialize = specialize; + } + public String getLabel() { return label; } Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/WikittyFieldTag.java =================================================================== --- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/WikittyFieldTag.java 2011-06-24 13:51:08 UTC (rev 974) +++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/WikittyFieldTag.java 2011-06-24 15:13:20 UTC (rev 975) @@ -5,6 +5,7 @@ import org.apache.struts2.components.Component; import org.apache.struts2.views.jsp.ui.AbstractClosingTag; +import org.nuiton.wikitty.struts.component.FieldSpecialisation; import org.nuiton.wikitty.struts.component.WikittyFieldTagBean; import com.opensymphony.xwork2.util.ValueStack; @@ -19,7 +20,25 @@ protected String subtype; protected String criteria; protected String type; + protected String fixvalues; + protected String descfields; + + public String getFixvalues() { + return fixvalues; + } + public void setFixvalues(String fixvalues) { + this.fixvalues = fixvalues; + } + + public String getDescfields() { + return descfields; + } + + public void setDescfields(String descfields) { + this.descfields = descfields; + } + public String getSubtype() { return subtype; } @@ -55,11 +74,15 @@ protected void populateParams() { super.populateParams(); WikittyFieldTagBean fieldtag = ((WikittyFieldTagBean) component); - fieldtag.setName(name); - fieldtag.setType(type); - fieldtag.setSubtype(subtype); - fieldtag.setCriteria(criteria); - + + FieldSpecialisation spe = new FieldSpecialisation(); + spe.setName(name); + spe.setType(type); + spe.setSubtype(subtype); + spe.setCriteria(criteria); + spe.setFixvalues(fixvalues); + spe.setDescfields(descfields); + fieldtag.setSpecialize(spe); } public String getName() { Modified: trunk/wikitty-struts/src/main/tld/wikitty-struts.tld =================================================================== --- trunk/wikitty-struts/src/main/tld/wikitty-struts.tld 2011-06-24 13:51:08 UTC (rev 974) +++ trunk/wikitty-struts/src/main/tld/wikitty-struts.tld 2011-06-24 15:13:20 UTC (rev 975) @@ -76,9 +76,18 @@ <name>criteria</name> <rtexprvalue>true</rtexprvalue> </attribute> + + <attribute> + <name>fixvalues</name> + <rtexprvalue>true</rtexprvalue> + </attribute> + + <attribute> + <name>descfields</name> + <rtexprvalue>true</rtexprvalue> + </attribute> </tag> - </taglib>