Skip to content

Instantly share code, notes, and snippets.

@0xRoch
Created June 21, 2011 22:23
Show Gist options
  • Save 0xRoch/1039075 to your computer and use it in GitHub Desktop.
Save 0xRoch/1039075 to your computer and use it in GitHub Desktop.
//form.html
#{list items:_fields ?: currentType.fields*.name, as:'fieldName'}
%{x++}%
<div id="${x}" style="height: 20px;">
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#${x}').load('@{CRUD.loadField(fieldName)}');
});
</script>
#{/list}
//crud.java
public static void loadField(String id, String field) {
ObjectType type = ObjectType.get(getControllerClass());
notFoundIfNull(type);
Object object = SienaModelUtils.findById(type.entityClass, id);
Object field = object.getClass().getField(field).get(object);
render("CRUD/field.html", field);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment