diff --git a/src/main/java/org/jminix/console/resource/AbstractTemplateResource.java b/src/main/java/org/jminix/console/resource/AbstractTemplateResource.java index e8bbea8..0b86f59 100644 --- a/src/main/java/org/jminix/console/resource/AbstractTemplateResource.java +++ b/src/main/java/org/jminix/console/resource/AbstractTemplateResource.java @@ -45,6 +45,7 @@ public abstract class AbstractTemplateResource extends ServerResource private final static String VELOCITY_ENGINE_CONTEX_KEY = "template.resource.velocity.engine"; protected final static String ATTRIBUTE_MODEL_ATTRIBUTE = "attribute"; protected final static String VALUE_MODEL_ATTRIBUTE = "value"; + protected final static String VALUE_TYPE_MODEL_ATTRIBUTE = "valueType"; protected final static String ITEMS_MODEL_ATTRIBUTE = "items"; protected final EncoderBean encoder = new EncoderBean(); diff --git a/src/main/java/org/jminix/console/resource/AttributeResource.java b/src/main/java/org/jminix/console/resource/AttributeResource.java index 5f41232..af4f4b0 100644 --- a/src/main/java/org/jminix/console/resource/AttributeResource.java +++ b/src/main/java/org/jminix/console/resource/AttributeResource.java @@ -109,6 +109,17 @@ public Map getModel() } else if(value instanceof TabularData){ templateName = "tabular-attribute"; model.put(VALUE_MODEL_ATTRIBUTE, value); + } else { + model.put(VALUE_MODEL_ATTRIBUTE, value); + String valueType; + if (value instanceof Boolean) { + valueType = "checkbox"; + } else if (value instanceof Number) { + valueType = "number"; + } else { + valueType = "text"; + } + model.put(VALUE_TYPE_MODEL_ATTRIBUTE, valueType); } return model; @@ -173,6 +184,7 @@ public void update(Representation entity) throws ResourceException for(MBeanAttributeInfo info : server.getMBeanInfo(new ObjectName(domain+":"+mbean)).getAttributes()) { if(info.getName().equals(attributeName)) { type = info.getType(); + break; } } diff --git a/src/main/resources/jminix/templates/attribute.vm b/src/main/resources/jminix/templates/attribute.vm index f87cb21..7355823 100644 --- a/src/main/resources/jminix/templates/attribute.vm +++ b/src/main/resources/jminix/templates/attribute.vm @@ -5,7 +5,15 @@ $!{attribute.description} #end #if ($attribute.writable) -
+ +#if ($valueType=="checkbox") + +#elseif ($valueType=="number") + +#else + +#end + #if($ok) Done