timezone - How to display Selected option Of timeZoneSelect Tag in grails -
when creating customer timezone, timezone have value. when show timezone ,i want display selected option.
for example, want display sst, samoa standard time -11:0.0(selected option) rather pacific/midway(value).
what have change in show page functionality?
class customer {
static constraints = { } string name string timezone } in create.gsp:
<div class="fieldcontain ${haserrors(bean: customerinstance, field: 'timezone', 'error')} "> <label for="timezone"> <g:message code="customer.timezone.label" default="timezone" /> </label> <g:if test="${customerinstance?.timezone}"> <g:timezoneselect name="timezone" value="${timezone.gettimezone(customerinstance?.timezone)}" /> </g:if> <g:else> <g:timezoneselect name="timezone" value="${customerinstance?.timezone}" /> </g:else> </div> in show.gsp:
<span class="property-value" aria-labelledby="timezone-label"><g:fieldvalue bean="${customerinstance}" field="timezone"/></span>
i have found solution
def show(long id) { def customerinstance = customer.get(id) if (!customerinstance) { flash.message = message(code: 'default.not.found.message', args: [message(code: 'customer.label', default: 'customer'), id]) redirect(action: "list") return } def date = new date() timezone tz = timezone.gettimezone(customerinstance.timezone); def shortname = tz.getdisplayname(tz.indaylighttime(date), timezone.short); def longname = tz.getdisplayname(tz.indaylighttime(date), timezone.long); def offset = tz.rawoffset; def hour = offset / (60 * 60 * 1000); def min = math.abs(offset / (60 * 1000)) % 60; def timezone= shortname+", "+longname+" "+hour+": "+min [customerinstance: customerinstance,timezone:timezone] } in show.gsp:
<span class="property-value" aria-labelledby="timezone-label">${timezone}</span>
Comments
Post a Comment