Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.2
-
Component/s: ICE-Components
-
Labels:None
-
Environment:ICEfaces 2 MyFaces
Description
When running the compat Component Showcase, when you use down the month and year pulldowns of the popup calender, the selection reverts back to the default values (current month and year).
Issue Links
- blocks
-
ICE-5868 MyFaces 2 compatibility
- Closed
Activity
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #24969 | Thu Jul 07 10:38:47 MDT 2011 | deryk.sinotte | |
Files Changed | ||||
MODIFY
/icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java
|
Deryk Sinotte
created issue -
Deryk Sinotte
made changes -
Field | Original Value | New Value |
---|---|---|
Salesforce Case | [] | |
Assignee | Deryk Sinotte [ deryk.sinotte ] |
Deryk Sinotte
made changes -
Deryk Sinotte
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Ken Fyten
made changes -
Fix Version/s | 2.1-Beta [ 10291 ] |
Ken Fyten
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
The reason is that the HtmlSelectOneMenus that are used internally in the SelectInputDateRenderer are not getting the proper client id. They are rendering out:
id="popupDatePttrn1_sm"
instead of:
id="iceform:popupDatePttrn1_sm"
The missing portion is the id for the naming container. The reason turns out to be the order of operations for dynamically adding and removing the component itself. In SelectInputDateRenderer methods .writeMonthDropdown and writeYearDropdown, the items are added to the menu before the menu is added to the calendar:
HtmlSelectOneMenu dropDown = new HtmlSelectOneMenu();
dropDown.setId(component.getId() + SELECT_MONTH);
dropDown.setPartialSubmit(true);
dropDown.setTransient(true);
dropDown.setImmediate(component.isImmediate());
dropDown.setDisabled(component.isDisabled() || component.isReadonly());
dropDown.setStyleClass(component.getMonthYearDropdownClass());
UISelectItem selectItem;
{ dropDown.setValue(selectItem.getItemValue()); }Calendar calendar;
int currentMonth = timeKeeper.get(Calendar.MONTH);
for (int i = 0; i < months.length; i++) {
selectItem = new UISelectItem();
calendar = shiftMonth(facesContext, timeKeeper, currentDay, i - currentMonth);
selectItem.setItemValue(converter.getAsString(facesContext, component, calendar.getTime()));
selectItem.setItemLabel(months[i]);
dropDown.getChildren().add(selectItem);
if (i == currentMonth)
}
//The menu is added as a child of the calendar after the menu items are set. This works in Mojarra but not MyFaces
component.getChildren().add(dropDown);
dropDown.encodeBegin(facesContext);
dropDown.encodeChildren(facesContext);
dropDown.encodeEnd(facesContext);
component.getChildren().remove(dropDown);
MyFaces doesn't like this because adding the menu to the calendar has the side effect of setting the parent and allowing the client id to be calculated. To appease both MyFaces and Mojarra, we just have to move the logic adding the menu to the calendar before we start setting the actual menu items:
HtmlSelectOneMenu dropDown = new HtmlSelectOneMenu();
dropDown.setId(component.getId() + SELECT_MONTH);
dropDown.setPartialSubmit(true);
dropDown.setTransient(true);
dropDown.setImmediate(component.isImmediate());
dropDown.setDisabled(component.isDisabled() || component.isReadonly());
dropDown.setStyleClass(component.getMonthYearDropdownClass());
//Add the menu to the calendar's children before adding any menu items.
component.getChildren().add(dropDown);
UISelectItem selectItem;
Calendar calendar;
int currentMonth = timeKeeper.get(Calendar.MONTH);
for (int i = 0; i < months.length; i++) {
selectItem = new UISelectItem();
calendar = shiftMonth(facesContext, timeKeeper, currentDay, i - currentMonth);
selectItem.setItemValue(converter.getAsString(facesContext, component, calendar.getTime()));
selectItem.setItemLabel(months[i]);
dropDown.getChildren().add(selectItem);
if (i == currentMonth) { dropDown.setValue(selectItem.getItemValue()); }
}
dropDown.encodeBegin(facesContext);
dropDown.encodeChildren(facesContext);
dropDown.encodeEnd(facesContext);
component.getChildren().remove(dropDown);