r204 - in trunk/chorem-webmotion/src/main: java/org/wikitty/web/jsptag webapp/WEB-INF webapp/WEB-INF/jsp/employee webapp/WEB-INF/jsp/person
Author: ymartel Date: 2012-07-03 14:52:32 +0200 (Tue, 03 Jul 2012) New Revision: 204 Url: http://chorem.org/repositories/revision/chorem/204 Log: ref #674 Add label option for wikitty display tag Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/wikitty.tld Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java 2012-07-03 09:46:27 UTC (rev 203) +++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java 2012-07-03 12:52:32 UTC (rev 204) @@ -48,21 +48,10 @@ */ public class WikittyDisplay extends SimpleTagSupport { - - protected String name=""; - protected Object value=""; - protected Wikitty wikitty; protected String fqfield=""; + protected String label=""; - public void setName(String name) { - this.name = name; - } - - public void setValue(Object value) { - this.value = value; - } - public void setWikitty(Wikitty wikitty) { this.wikitty = wikitty; } @@ -71,12 +60,12 @@ this.fqfield = fqfield; } + public void setLabel(String label) { + this.label = label; + } + @Override public void doTag() throws JspException, IOException { - // par defaut si pas de name on utilise celui du field - if (StringUtils.isBlank(name)) { - name = fqfield; - } JspWriter output = getJspContext().getOut(); PageContext pageContext = (PageContext)getJspContext(); @@ -87,32 +76,37 @@ String fieldName = WikittyUtil.getFieldNameFromFQFieldName(fqfield); FieldType field = wikitty.getFieldType(fqfield); + // par defaut si pas de label on utilise le nom du field + if (StringUtils.isBlank(label)) { + label = fieldName; + } + if (field != null) { switch(field.getType()) { case BINARY: - viewBinary(output, contextPath, name, wikitty, field, extName, fieldName); + viewBinary(output, contextPath, label, wikitty, extName, fieldName); break; case BOOLEAN: - viewBoolean(output, contextPath, name, wikitty, field, extName, fieldName); + viewBoolean(output, contextPath, label, wikitty, extName, fieldName); break; case DATE: - viewDate(output, contextPath, name, wikitty, field, extName, fieldName); + viewDate(output, contextPath, label, wikitty, field, extName, fieldName); break; case NUMERIC: - viewNumeric(output, contextPath, name, wikitty, field, extName, fieldName); + viewNumeric(output, contextPath, label, wikitty, field, extName, fieldName); break; case STRING: if (field.isCollection()) { - viewCollectionString(output, contextPath, name, wikitty, field, extName, fieldName); + viewCollectionString(output, contextPath, label, wikitty, extName, fieldName); } else { - viewString(output, contextPath, name, wikitty, field, extName, fieldName); + viewString(output, label, wikitty, extName, fieldName); } break; case WIKITTY: if (field.isCollection()) { - viewCollectionWikitty(output, contextPath, name, wikitty, field, extName, fieldName); + viewCollectionWikitty(output, contextPath, label, wikitty, extName, fieldName); } else { - viewWikitty(output, contextPath, name, wikitty, field, extName, fieldName); + viewWikitty(output, contextPath, label, wikitty, extName, fieldName); } break; } @@ -121,26 +115,26 @@ } } - protected void viewBinary(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) + protected void viewBinary(JspWriter output, String contextPath, String label, + Wikitty wikitty, String extName , String fieldName) throws JspException, IOException { byte[] fieldAsBytes = wikitty.getFieldAsBytes(extName, fieldName); if (fieldAsBytes != null) { String url = contextPath + "/wikitty/view/" + wikitty.getId() + "/" + extName + "/" + fieldName; - /*{<%=name%> : <a href="<%=url%>">Download</a>}*/ + /*{<%=label%> : <a href="<%=url%>">Download</a>}*/ } else { - /*{<%=name%> : }*/ + /*{<%=label%> : }*/ } } - protected void viewBoolean(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) + protected void viewBoolean(JspWriter output, String contextPath, String label, + Wikitty wikitty, String extName , String fieldName) throws JspException, IOException { boolean value = wikitty.getFieldAsBoolean(extName, fieldName); - /*{<%=fieldName%> : <%=value%>}*/ + /*{<%=label%> : <%=value%>}*/ } - protected void viewDate(JspWriter output, String contextPath, String name, + protected void viewDate(JspWriter output, String contextPath, String label, Wikitty wikitty, FieldType field, String extName , String fieldName) throws JspException, IOException { Date date = wikitty.getFieldAsDate(extName, fieldName); @@ -157,10 +151,10 @@ value = DateFormatUtils.format(date, "dd/MM/yyyy"); } } - /*{<%=fieldName%> : <%=value%> }*/ + /*{<%=label%> : <%=value%> }*/ } - protected void viewNumeric(JspWriter output, String contextPath, String name, + protected void viewNumeric(JspWriter output, String contextPath, String label, Wikitty wikitty, FieldType field, String extName , String fieldName) throws JspException, IOException { BigDecimal value = wikitty.getFieldAsBigDecimal(extName, fieldName); @@ -170,18 +164,17 @@ //TODO ymartel 2012-05-02 : manage localization NumberFormat formatter = new DecimalFormat(pattern); String formattedValue = formatter.format(value); - /*{<%=fieldName%> : <%=formattedValue%> }*/ + /*{<%=label%> : <%=formattedValue%> }*/ } else { - /*{<%=fieldName%> : <%=value%>}*/ + /*{<%=label%> : <%=value%>}*/ } } - protected void viewCollectionString(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) + protected void viewCollectionString(JspWriter output, String contextPath, String label, + Wikitty wikitty, String extName , String fieldName) throws JspException, IOException { - String id = wikitty.getId() + "-" + extName + "-" + fieldName; List<String> values = wikitty.getFieldAsList(extName, fieldName, String.class); - /*{<%=fieldName%> : <ul>}*/ + /*{<%=label%> : <ul>}*/ if (values != null) { for (String value : values) { if (value != null) { @@ -192,19 +185,18 @@ /*{</ul>}*/ } - protected void viewString(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) + protected void viewString(JspWriter output, String label, Wikitty wikitty, String extName , String fieldName) throws JspException, IOException { String fieldAsString = wikitty.getFieldAsString(extName, fieldName); String value = fieldAsString != null ? fieldAsString : ""; - /*{<%=fieldName%> : <%=value%>}*/ + /*{<%=label%> : <%=value%>}*/ } - protected void viewCollectionWikitty(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) + protected void viewCollectionWikitty(JspWriter output, String contextPath, String label, + Wikitty wikitty, String extName , String fieldName) throws JspException, IOException { List<Wikitty> values = wikitty.getFieldAsWikittyList(extName, fieldName, false); - /*{<%=fieldName%> : <ul>}*/ + /*{<%=label%> : <ul>}*/ if (values != null) { for (Wikitty value : values) { if (value != null) { @@ -217,15 +209,15 @@ } - protected void viewWikitty(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) + protected void viewWikitty(JspWriter output, String contextPath, String label, + Wikitty wikitty, String extName , String fieldName) throws JspException, IOException { String value = wikitty.getFieldAsWikitty(extName, fieldName); Wikitty wikittyValue = wikitty.getFieldAsWikitty(extName, fieldName, false); if (wikittyValue != null) { String url = contextPath + "/wikitty/view/" + value; if (wikittyValue != null) { - /*{<%=fieldName%>: <a href="<%=url%>"><%=wikittyValue%></a>}*/ + /*{<%=label%>: <a href="<%=url%>"><%=wikittyValue%></a>}*/ } } } Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp 2012-07-03 09:46:27 UTC (rev 203) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp 2012-07-03 12:52:32 UTC (rev 204) @@ -35,19 +35,19 @@ <dl><dt><a href="<c:url value="/wikitty/Employee/search"/>">Employé</a> <a class="btn btn-success btn-mini" href="<c:url value="/wikitty/Employee/edit/${wikitty.id}"/>"><i class="icon-pencil icon-white"></i> Edit</a> <a class="btn btn-danger btn-mini" href="<c:url value="/wikitty/delete/${wikitty.id}?extension=Employee&wmDecoratorNo=true"/>"><i class="icon-trash icon-white"></i> Delete</a></dt> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.company"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.person"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.description"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.salary"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.paidLeave"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.rtt"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.type"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Employee.workingTime"/></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.company" label="Société" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.person" label="Personne" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.description" label="Description" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.salary" label="Salaire" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.paidLeave" label="Congès payés" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.rtt" label="RTT" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.type" label="Contrat" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Employee.workingTime" label="Temps de travail" /></dd> </dl> <dl> <dt><a href="<c:url value="/wikitty/search?extension=${ext.name}"/>">${ext.name}</a> - <dd><w:display wikitty="${wikitty}" fqfield="Interval.beginDate"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Interval.endDate"/></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Interval.beginDate" label="Date d'embauche" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Interval.endDate" label="Date de départ" /></dd> </dl> <p> Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp 2012-07-03 09:46:27 UTC (rev 203) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp 2012-07-03 12:52:32 UTC (rev 204) @@ -35,10 +35,10 @@ <dl><dt><a href="<c:url value="/wikitty/Person/search"/>">Personne</a> <a class="btn btn-success btn-mini" href="<c:url value="/wikitty/Person/edit/${wikitty.id}"/>"><i class="icon-pencil icon-white"></i> Edit</a> <a class="btn btn-danger btn-mini" href="<c:url value="/wikitty/delete/${wikitty.id}?extension=Person&wmDecoratorNo=true"/>"><i class="icon-trash icon-white"></i> Delete</a></dt> - <dd><w:display wikitty="${wikitty}" fqfield="Person.firstName"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Person.lastName"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Person.birthDate"/></dd> - <dd><w:display wikitty="${wikitty}" fqfield="Person.diploma"/></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.lastName" label="Nom" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.firstName" label="Prénom" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.birthDate" label="Date de naissance" /></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.diploma" label="Diplôme" /></dd> </dl> <p> Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/wikitty.tld =================================================================== (Binary files differ)
participants (1)
-
ymartel@users.chorem.org