The checkbox is a bit tricky.  It can be bound to either a String, Boolean
or boolean.  Obviously if you bind it to a boolean, we alway have a value
(true or false) and therefore the default value is never used.  For both a
String or Boolean if you are binding to a property with a null value the
default value should be picked up correctly.  Here is a small sample
(binding directly to a pageflow) that works as expected.

Page Flow:
package pf;

import org.apache.beehive.netui.pageflow.Forward;
import org.apache.beehive.netui.pageflow.PageFlowController;
import org.apache.beehive.netui.pageflow.annotations.Jpf;

import javax.servlet.http.HttpSession;

@Jpf.Controller()
public class PfController extends PageFlowController {
    private static final long serialVersionUID = -202669425L;

    private boolean _checkOne;
    private String _checkTwo;
    private Boolean _checkThree;

    public boolean getCheckOne()
    {
        return _checkOne;
    }
    public void setCheckOne(boolean value) {
        _checkOne = value;
    }

    public String getCheckTwo()
    {
        return _checkTwo;
    }
    public void setCheckTwo(String value) {
        _checkTwo = value;
    }

    public Boolean getCheckThree()
    {
        return _checkThree;
    }
    public void setCheckThree(Boolean value)
    {
        _checkThree = value;
    }

    @Jpf.Action(forwards = { @Jpf.Forward(name = "index", path = "index.jsp")
})
    protected Forward begin() {
        return new Forward("index");
    }
}

Index.jsp:

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<[EMAIL PROTECTED] uri="http://beehive.apache.org/netui/tags-html-1.0";
prefix="netui"%>
<[EMAIL PROTECTED] uri="http://beehive.apache.org/netui/tags-databinding-1.0";
prefix="netui-data"%>
<[EMAIL PROTECTED] uri="http://beehive.apache.org/netui/tags-template-1.0";
prefix="netui-template"%>
<netui:html>
    <head>
        <netui:base/>
    </head>
    <netui:body>
       <p>
           CheckOne: <netui:checkBox dataSource="pageFlow.checkOne"
defaultValue="true" /><br>
           CheckTwo: <netui:checkBox dataSource="pageFlow.checkTwo"
defaultValue="true" /><br>
           CheckThree: <netui:checkBox dataSource="pageFlow.checkThree"
defaultValue="true" /><br>
       </p>
    </netui:body>
</netui:html>



On 11/28/05, Eddie O'Neil <[EMAIL PROTECTED]> wrote:
>
> Chris--
>
>   What is the type of the property referred to by the
> "${actionForm.registrationRequired}" expression?  Is it a boolean or a
> Boolean?
>
>   In order for the defaultValue attribute to have any effect, it must
> be a null Boolean value.  Otherwise, the value of the dataSource
> (whether non-null or a primitive boolean type) will always win.
>
> Eddie
>
>
> On 11/21/05, Chris Jolley <[EMAIL PROTECTED]> wrote:
> > Is there a know issue with the defaultValue attribute for the
> > <netui:checkBox/>  tag. I am unable to get it to honor any value whether
> > a String, primitive or Boolean object, and whether a literal or
> > databinding expression
> >
> >
> >
> > The documentation looks like a cut and past from <netui:textBox/>. BTW:
> > the default value for textbox works just fine.
> >
> >
> >
> >
> >
> > I should be able to do something like
> >
> >
> >
> > <netui:checkBox dataSource="actionForm.registrationRequired"
> > defaultValue="${pageInput.communityPropertiesForm.registrationRequired}"
> > />
> >
> >
> >
> >
> >
>

Reply via email to