I am in the process of fixing this bug
But this is not as straightforward as i hope it to be... :(

I can just do this, change:

FormComponent.getInput()
{
        return getRequest().getParameter(getInputName());
}

into

FormComponent.getInput()
{
        String value = getRequest().getParameter(getInputName());
        // If value == null then value is not in the paramer map of the request, (disabled)
        if(value == null) value = getModelValue();
        return value;
}


This pretty much works for all components and readonly things will not be overridden by null.
But it doesn't work for checkboxes, because those are not submitted when it is not checked! (as far as i know)

so this must be done in all the updateModel methods of the various FormComponents  like change this:

public void updateModel()
    {
        String input = getInput();
        if (input != null && getConvertEmptyInputStringToNull() && Strings.isEmpty(input))
        {
            input = null;
        }
        setModelObject(input);
    }

into this:

public void updateModel()
    {
        String input = getInput();
        // skip null input, read only input..
        if(input != null)
        {
           if (input != null && getConvertEmptyInputStringToNull() && Strings.isEmpty(input))
           {
               input = null;
           }
           setModelObject(input);
        }
    }

This would pretty much work for everything
Except again the checkbox.
then can't have this check because of true/false setting
But what do do with a readonly checkbox that is selected??

The input is not submitted because of its readonly nature (this is also true for a checkbox i take)
but i can't test for null because this is a valid request value..

So especially for checkboxes we need a isDisabled state..
which we should introduce for all form components) but we have to check for null as much as possible anyway
because readonly can also be done by the designer.


On 9/14/05, SourceForge.net <[EMAIL PROTECTED]> wrote:
Bugs item #1290938, was opened at 2005-09-14 20:12
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1290938&group_id=119783

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: core
Group: 1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Ingram Chen (ingramchen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Disabled Form component update model as null

Initial Comment:
One can use AttributeModifier to control form component
enable/disable, see below:

class User {
    public String name ;
}

// An AccountForm for both create and edit:
public AccountForm(String id, User user) {
   super(id, new CompoundPropertyModel(user));
   TextField nField = new TextField("name");

   nField.add(new AttributeModifier(
             "disabled", true, new Model( user.getName())));

   nField.add(RequiredValidator.getInstance()) ;
}

While in creating, user.getName() return null, so
TextField("name") is not disable

While in editing, user.getName() return, say,
"foo", the field will be disabled with a attribute
disabled="foo" (browser disable the field no matter
what value is).

OK... the problem here is when editing, the field is
populated with "foo" and disabled. After the user
submit the form, I found that TextField("name") get
null value from request parameter and does not pass the
validator. And finally the TextField("name") update the
model with null value.

A disabled TextField should not get request parameter
and should not update the model. Maybe it should bypass
validation too...

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1290938&group_id=119783


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to