@SuppressWarnings("unchecked")
static public void service(FacesContext context)
throws IOException
{
RenderingContext arc = RenderingContext.getCurrentInstance();
CoreDocument doc = new CoreDocument();
context.getViewRoot().getChildren().add(doc);
doc.setTitle(arc.getTranslatedString(_DIALOG_TITLE_KEY));
CoreForm form = new CoreForm();
doc.getChildren().add(form);
form.setId("a");
boolean isDesktop = (arc.getAgent().getType().equals(Agent.TYPE_DESKTOP));
//
// Create the calendar row
//
UIComponent calendarRow = _createRow(isDesktop,
XhtmlConstants.H_ALIGN_END);
CoreChooseDate ccd = CalendarUtils.createChooseDate(context);
calendarRow.getChildren().add(ccd);
// Get a destination that points back to this dialog, including
// any viewIDs
String destination =
GenericEntry.getGenericEntryURL(context,
GenericEntry.CALENDAR_DIALOG_ENTRY);
ccd.getAttributes().put("destination", destination);
//
// Create a spacer
//
UIComponent spacerRow = _createRow(isDesktop, null);
CoreSpacer cos = new CoreSpacer();
spacerRow.getChildren().add(cos);
cos.setHeight("8");
//
// Create the button row
//
UIComponent buttonRow = _createRow(isDesktop, XhtmlConstants.H_ALIGN_END);
CoreGoButton cancelButton =
JspUtils.createGoButton(arc, _CANCEL_LABEL_KEY);
buttonRow.getChildren().add(cancelButton);
Object cap = arc.getAgent().getCapabilities().get(
TrinidadAgent.CAP_MULTIPLE_WINDOWS);
boolean multWindowsSupported = Boolean.TRUE.equals( cap );
if (multWindowsSupported )
{
cancelButton.setOnclick("return _doCancel()");
}
else
{
// create the destination of the cancel button
StringBuffer cancelDest = new StringBuffer();
EncoderUtils.appendURLArguments(cancelDest,
destination,
new String[]{
TrinidadRenderingConstants.EVENT_PARAM,
TrinidadRenderingConstants.CANCEL_EVENT
});
// Prepend a slash, because this destination already
// includes the context root
cancelButton.setDestination("/" + cancelDest.toString());
String value = __getParam(context, TrinidadRenderingConstants.VALUE_PARAM);
if (value != null)
{
long lg = Long.parseLong(value);
ccd.getAttributes().put("value", new Date(lg));
}
// get the scrolled value
String month = __getParam(context,TrinidadRenderingConstants.MONTH_PARAM);
String year = __getParam(context,TrinidadRenderingConstants.YEAR_PARAM);
// try to create scrolledValue
if ( month != null && year != null )
{
try
{
long scrolledValue = Long.parseLong(month) + Long.parseLong(year);
ccd.getAttributes().put("scrolledValue", new Date(scrolledValue));
}
catch ( NumberFormatException nfe){;}
}
}
if (multWindowsSupported )
{
CoreImportScript cis = new CoreImportScript();
cis.setNames(new String[]{"_doCancel()", "_selectDate()"});
doc.getFacets().put(CoreDocument.META_CONTAINER_FACET, cis);
HtmlTableLayout htl = new HtmlTableLayout();
form.getChildren().add(htl);
//