[ http://issues.apache.org/jira/browse/BEEHIVE-396?page=history ]
Daryl Olander resolved BEEHIVE-396:
-----------------------------------
Resolution: Fixed
So I made the defaultValue a boolean. The intention for this is that you would
set the value as a boolean "true"/"false" or bind to a Boolean. So the test
isn't really invalid, but I believe the way that JSP works, for a boolean, it
is legal to do this and the boolean default will be false.
In general, I don't think this is the right behavior for repeating
CheckBoxOptions. The right behavior would be to databind to some type of class
tha thas a boolean property that sets the default value of the checkbox
instance. So you would bind like this
<checkBoxOption defaultValue="${container.item.default}"
value="${container.item.value}" />
> <netui:CheckBoxOption defaultValue doesn't take any expression or non-boolean
> -----------------------------------------------------------------------------
>
> Key: BEEHIVE-396
> URL: http://issues.apache.org/jira/browse/BEEHIVE-396
> Project: Beehive
> Type: Bug
> Components: NetUI
> Versions: V1Beta
> Reporter: David Madrid
> Assignee: Daryl Olander
>
> DefaultValue for checkBoxOption only allows a "true" of "false" value. It
> should also allow an explicit string or expression that resolves to checked,
> unchecked, String or String[] values that match any option values.
> My resutls:
> defaultValue=
> "checked" - ignored
> "unchecked" - ignored
> "${any.expression}" - ignored
> "true" - this works, generates html checked="checked" for all options.
> "false" - this works. It will override the defaultValue in checkBoxGroup tag
> if set.
> Note: According to the tld, CheckBoxOption should take a runtime expression.
> *** TLD ***
> <description><![CDATA[A checkbox whose state is determined by its
> enclosing CheckBoxGroup.]]></description>
> <name>checkBoxOption</name>
>
> <tag-class>org.apache.beehive.netui.tags.html.CheckBoxOption</tag-class>
>
> <attribute>
> <description><![CDATA[Sets the default value.]]></description>
> <name>defaultValue</name>
> <required>false</required>
> <rtexprvalue>true</rtexprvalue>
> </attribute>
> *****
> - Test Case:
> 1. Create a jsp:
> <netui:form action="post">
> <netui:checkBoxGroup dataSource="pageFlow.resultsThree"
> optionsDataSource="${pageFlow.checkGroupOptions}" repeater="true" >
> <netui:span styleClass="normal" value="${container.item}" />
> <netui:checkBoxOption defaultValue="Check 1"
> value="${container.item}" />
> </netui:checkBoxGroup>
> <netui:button value="Post" />
> </netui:form>
> 2. Create a Controller.jpf:
> // Results Three
> private String resultsThree;
> public String getResultsThree()
> {
> return resultsThree;
> }
>
> public void setResultsThree(String resultsThree)
> {
> this.resultsThree = resultsThree;
> }
> private String[] _checkGroupOptions = {"Check 1", "Check 2", "Check
> 3",
> "Default Check 1",
> "Default Check 2"};
> public String[] getCheckGroupOptions() {
> return _checkGroupOptions;
> }
> 3. Run the JSP and see that "Check 1" checkbox is NOT selected.
> - Expected Results:
> Checkbox "Check 1" should be selected and html source should have
> checked="checked".
> - Actual Results:
> Checkbox "Check 1" is NOT selected and html source does NOT have
> checked="checked".
> - Root Cause:
> I think this might be because checkBoxOption.setDefaultValue() needs
> another case to set:
> _defaultValue = defaultValue.toString();
> Right now, if defaultValue="Check 1", none of these cases are a match,
> so _defaultValue is set to false:
> else {
> _defaultValue = Boolean.valueOf(defaultValue.toString());
> ==== CheckBoxOption.setDefaultValue() ====
> /**
> * Sets the default value (can be an expression).
> * @param defaultValue - the default value
> * @netui:attribute required="false" rtexprvalue="true"
> * description="Sets the default value."
> * @netui.tldx:attribute
> */
> public void setDefaultValue(Object defaultValue)
> throws JspException
> {
> if (defaultValue == null) {
> String s = Bundle.getString("Tags_AttrValueRequired", new
> Object[]{"defaultValue"});
> registerTagError(s, null);
> return;
> }
> if (defaultValue instanceof Boolean) {
> _defaultValue = (Boolean) defaultValue;
> }
> else {
> _defaultValue = Boolean.valueOf(defaultValue.toString());
> }
> }
> - There are no other exceptions or errors.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira