Some Title Any
Tuesday, May 20th, 2008Verify
Technorati Profile
Verify
Technorati Profile
I really like scaffolding in grails. However I don’t like the scaffolding for the create, edit, and show. So I decided to hack up the templates. I’m not sure if there is a better way to have custom scaffolding templates. Please post if you have a good way since over riding the default might not be the best approach.
Here’s my hacked up version to use the dl, dt, and dd for create.gsp and the style sheet. The style sheet is not perfect yet but soon will be very close.
.....
<%= multiPart ? ' enctype="multipart/form-data"' : '' %>></code>
<div class="dialog"><fieldset>
<legend>Create ${className}</legend>
<%
excludedProps = [’version’,
‘id’,
Events.ONLOAD_EVENT,
Events.BEFORE_DELETE_EVENT,
Events.BEFORE_INSERT_EVENT,
Events.BEFORE_UPDATE_EVENT]
props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.each { p ->
if(p.type != Set.class) {
cp = domainClass.constrainedProperties[p.name]
display = (cp ? cp.display : true)
if(display) { %>
<dl class=”table-display prop”> <dt class=”name”> <label for=”${p.name}”>${p.naturalName}:</label> </dt> <dd class=”value \${hasErrors(bean:${domainClass.propertyName},field:’${p.name}’,'errors’)}”> ${renderEditor(p)} </dd> </dl><% } } } %>
</fieldset>
<div class=”buttons”><span class=”button”><input class=”save” type=”submit” value=”Create” /></span></div>
</div>
….
Okay Word Press doesn’t do it justice.
fieldset {
border: 1px solid #336699;
font-family: Verdana;
font-size: 12px;
line-height: 15px;
margin: 0px 0px 5px;
padding: 0px 5px 8px;
float: left;
}
fieldset legend {
font-weight: bold;
padding: 5px;
}
.table-display dt {
float: right;
font-weight: bold;
margin: 0pt;
padding: 0.2em;
text-align: right;
width:14em;
margin-top: .3em;
}
.table-display dd {
margin: 0pt;
padding: 0.2em;
}
dl.table-display {
margin: 0.2em 0pt;
padding: 0pt;
}
dd input {
height: 100%;
}
dd select {
height: 100%;
width: 100px;
}
dd.errors {
background: #fff3f3;
border: 1px solid red;
color: #cc0000;
margin: 10px 0 5px 0;
padding: 5px 0 5px 0;
}
Have to find a plugin to display code better.
If someone wants a better copy just email me.