1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | < screen name = "EditCalendarExceptionDay" > < section > < actions > < set field = "titleProperty" value = "PageTitleEditCalendarExceptionDay" ></ set > < set field = "tabButtonItem" value = "calendarExceptionDay" ></ set > < set field = "headerItem" value = "calendar" ></ set > < script location = "component://imas-manufacturing/webapp/imas-manufacturing/WEB-INF/actions/routing/EditCalendarExceptionDay.groovy" ></ script > </ actions > < widgets > < decorator-screen name = "CommonCalendarDecorator" > < decorator-section name = "body" > < section > < widgets > < platform-specific > < html-template location = "component://imas-manufacturing/webapp/imas-manufacturing/routing/EditCalendarExceptionDay.ftl" ></ html-template > </ platform-specific > </ widgets > </ section > </ decorator-section > </ decorator-screen > </ widgets > </ section > </ screen > |
จากในแท็ก actions จะเห็นว่ามีการเรียกใช้ไฟล์ groovy อยู่
1 | < script location = "component://imas-manufacturing/webapp/imas-manufacturing/WEB-INF/actions/routing/EditCalendarExceptionDay.groovy" ></ script > |
ถ้าเราไปดูในไฟล์ groovy เอง เราจะต้องเรียก form-widget ดังนี้ครับ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | techDataCalendar = [:]; calendarExceptionDays = []; calendarId = parameters.calendarId ?: request.getAttribute( "calendarId" ); if (calendarId) { techDataCalendar = delegator.findByPrimaryKey( "TechDataCalendar" , [calendarId : calendarId]); } if (techDataCalendar) { calendarExceptionDays = techDataCalendar.getRelated( "TechDataCalendarExcDay" ); } HtmlFormWrapper listCalendarExceptionDayWrapper = new HtmlFormWrapper( "component://imas-manufacturing/webapp/imas-manufacturing/routing/CalendarForms.xml" , "ListCalendarExceptionDay" , request, response); listCalendarExceptionDayWrapper.putInContext( "calendarExceptionDays" , calendarExceptionDays); context.listCalendarExceptionDayWrapper = listCalendarExceptionDayWrapper; |
จุดสำคัญอยู่ตรงนี้ครับ
1 2 3 4 | HtmlFormWrapper listCalendarExceptionDayWrapper = new HtmlFormWrapper( "component://imas-manufacturing/webapp/imas-manufacturing/routing/CalendarForms.xml" , "ListCalendarExceptionDay" , request, response); listCalendarExceptionDayWrapper.putInContext( "calendarExceptionDays" , calendarExceptionDays); context.listCalendarExceptionDayWrapper = listCalendarExceptionDayWrapper; |
ซึ่งตัว calendarExceptionDays ก็เป็นค่าที่ได้ส่งออกไปให้ form ส่วนใน form-widget ก็ทำการแมบค่าเข้าไปเลย ตัวอย่าง ในตัวของฟอร์ม list-name ส่วนตัว listCalendarExceptionDayWrapper จะถูเรียกในไฟล์ .ftl ครับ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | < form br = "" list-name = "calendarExceptionDays" name = "ListCalendarExceptionDay" target = "UpdateCalendarExceptionDay" title = "" type = "list" > odd-row-style="alternate-row" default-table-style="basic-table hover-bar"> < field name = "calendarId" >< hidden ></ hidden ></ field > < field name = "description" title = "${uiLabelMap.CommonDescription}" >< display ></ display ></ field > < field name = "exceptionDateStartTime" title = "${uiLabelMap.ManufacturingExceptionDateStartTime}" >< display type = "date" ></ display ></ field > < field name = "exceptionCapacity" title = "${uiLabelMap.ManufacturingCalendarCapacity}" >< display ></ display ></ field > < field name = "updateLink" title = "${uiLabelMap.CommonEmptyHeader}" widget-style = "buttontext" > < hyperlink description = "${uiLabelMap.CommonSelect}" target = "EditCalendarExceptionDay" > < parameter param-name = "calendarId" ></ parameter > < parameter param-name = "exceptionDateStartTime" ></ parameter > </ hyperlink > </ field > < field name = "deleteLink" title = "${uiLabelMap.CommonEmptyHeader}" > < hyperlink also-hidden = "false" image-location = "/admintheme/images/icons/cross.png" target = "RemoveCalendarExceptionDay" > < parameter param-name = "calendarId" ></ parameter > < parameter param-name = "exceptionDateStartTime" ></ parameter > </ hyperlink > </ field ></ form > |
สำหรับการแสดงผลเราจะใช้ ไฟล์ .ftl ในการแสดงผลครับ
1 2 3 4 5 6 7 8 9 10 11 12 13 | <div class = "screenlet" > <div class = "screenlet-title-bar" > <h3> ${uiLabelMap.ManufacturingEditCalendarExceptionDayFor} <# if (techDataCalendar.description)?has_content> "${(techDataCalendar.get(" description ",locale))}" <!--# if --> [${uiLabelMap.CommonId} ${techDataCalendar.calendarId?if_exists}]</h3> </div> <div class = "screenlet-body" > ${listCalendarExceptionDayWrapper.renderFormString(context)}</div> </div> |
จุดสำคัญอยู่ตรงนี้ครับ จากการ context มาจากไฟล์ groovy
1 | context.listCalendarExceptionDayWrapper = listCalendarExceptionDayWrapper; |
ซึ่งเราจะมาเรียกใช้จากข้อมูลที่ context มาจากไฟล์ groovy
1 | ${listCalendarExceptionDayWrapper.renderFormString(context)} |
0 comments:
Post a Comment