When specifying
a [selected] customEntry... (ie: customEntry =
"999,someValue,true")
In INSERT mode, this
should be the only option selected.
However, the select
tag uses the default value to set the option to be selected. In
INSERT mode, this is by default 0.
The problem is that
I have an option who's key is 0. Hence, I end up with 2 selected
options! (and the wrong one takes precedence!)
My change is to
reset the currentValue to the custom value when appropriate. (ie:
currentValue = 999)
See code extract
below.
public int doEndTag() throws
javax.servlet.jsp.JspException {
...
if (embeddedData != null) {
// PG, 2001-12-14
// Is their a custom entry? Display first...
String ce = null;
if
(((ce = this.getCustomEntry()) != null) &&
(ce.trim()
.length() > 0)) {
boolean isSelected = false;
String aKey = org.dbforms.util.StringUtil
.getEmbeddedStringWithoutDots(ce, 0, ',');
String aValue = org.dbforms.util.StringUtil
.getEmbeddedStringWithoutDots(ce, 1, ',');
.length() > 0)) {
boolean isSelected = false;
String aKey = org.dbforms.util.StringUtil
.getEmbeddedStringWithoutDots(ce, 0, ',');
String aValue = org.dbforms.util.StringUtil
.getEmbeddedStringWithoutDots(ce, 1, ',');
//
Check if we are in redisplayFieldsOnError mode and errors have
occured
// If so, only set to selected if currentRow is equal to custom row.
if ((getParentForm()
.hasRedisplayFieldsOnErrorSet() && (errors != null)
&& (errors.size() > 0))
|| ((we != null)
&& (we.getType().equals(EventType.EVENT_NAVIGATION_RELOAD)))) {
isSelected = (currentValue.equals(aKey));
} else {
isSelected = "true".equals(org.dbforms.util.StringUtil
.getEmbeddedStringWithoutDots(ce, 2,
','));
}
// If so, only set to selected if currentRow is equal to custom row.
if ((getParentForm()
.hasRedisplayFieldsOnErrorSet() && (errors != null)
&& (errors.size() > 0))
|| ((we != null)
&& (we.getType().equals(EventType.EVENT_NAVIGATION_RELOAD)))) {
isSelected = (currentValue.equals(aKey));
} else {
isSelected = "true".equals(org.dbforms.util.StringUtil
.getEmbeddedStringWithoutDots(ce, 2,
','));
}
if
(isSelected)
{
selectedOptions.append("-")
.append(aKey);
/* Philip Grunikiewicz
* 2005-12-05
*
* If in INSERT Mode and custom entry is set as default
*/
if (getParentForm().isFooterReached())
{
currentValue = aKey;
}
}
selectedOptions.append("-")
.append(aKey);
/* Philip Grunikiewicz
* 2005-12-05
*
* If in INSERT Mode and custom entry is set as default
*/
if (getParentForm().isFooterReached())
{
currentValue = aKey;
}
}
tagBuf.append(generateTagString(aKey, aValue,
isSelected));
}
}
...
}
DbSelectTag.java
Description: DbSelectTag.java
