You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Marieke Vandamme <ma...@tvh.be> on 2009/03/26 10:29:13 UTC

RadioGroup lost value after onError form

Hello, 

consider example underneath. 
Form with DateTextField and RadioGroup. When an incorrect date is entered in
the TextField, the value choosen in radiogroup is lost. When correct date is
entered, the value is shown correct in radiogroup.
Is this an error in my code? Or a bug?
I'm using wicket 1.4-rc2. 
Thanks for any help !!

==TestPage.java==
public class TestPage extends WebPage {
    private String color;
    private Date date;
    public TestPage(){
        Form myform = new Form("myform");
        myform.add(new FeedbackPanel("feedback"));
        myform.add(new DateTextField("date", new PropertyModel(this,
"date")));
        List<String> colors = Arrays.asList(new String[]{"green", "red",
"yellow"});
        myform.add(new RadioGroup("colors", new PropertyModel(this,
"color"))
                .add(new ListView<String>("color", colors) {
            @Override
            protected void populateItem(ListItem<String> item) {
                item.add(new Radio("radio", item.getModel()))
                        .add(new Label("value", item.getModelObject()));
            }
        }));
        add(myform);
    }

    public String getColor() {
        return color;
    }
    public void setColor(String color) {
        this.color = color;
    }
    public Date getDate() {
        return date;
    }
    public void setDate(Date date) {
        this.date = date;
    }
}

==TestPage.html==
<html>
    <head>
        <title></title>
    </head>
    <body>
        <form wicket:id="myform">
            <input type="submit"/>
            <wicket:container wicket:id="feedback"/>
            <input type="text" wicket:id="date"/><br/>
            <wicket:container wicket:id="colors">
                <table>
                    <tr wicket:id="color">
                        <td><input type="radio" wicket:id="radio"/></td>
                        <td wicket:id="value"></td>
                    </tr>
                </table>
            </wicket:container>
        </form>
    </body>
</html>

-- 
View this message in context: http://www.nabble.com/RadioGroup-lost-value-after-onError-form-tp22718553p22718553.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RadioGroup lost value after onError form

Posted by Igor Vaynberg <ig...@gmail.com>.
use repeatingview instead of listview, or call setreuseitems on the
listview. there is javadoc on the listview that warns you about this.

-igor

On Sun, Mar 29, 2009 at 11:55 PM, Marieke Vandamme <ma...@tvh.be> wrote:
>
> Hello,
>
> Can't anyone help me with this?
> Or do I just report a jira bug for this?
> THANKS!
>
>
> Marieke Vandamme wrote:
>>
>> Hello,
>>
>> consider example underneath.
>> Form with DateTextField and RadioGroup. When an incorrect date is entered
>> in the TextField, the value choosen in radiogroup is lost. When correct
>> date is entered, the value is shown correct in radiogroup.
>> Is this an error in my code? Or a bug?
>> I'm using wicket 1.4-rc2.
>> Thanks for any help !!
>>
>> ==TestPage.java==
>> public class TestPage extends WebPage {
>>     private String color;
>>     private Date date;
>>     public TestPage(){
>>         Form myform = new Form("myform");
>>         myform.add(new FeedbackPanel("feedback"));
>>         myform.add(new DateTextField("date", new PropertyModel(this,
>> "date")));
>>         List<String> colors = Arrays.asList(new String[]{"green", "red",
>> "yellow"});
>>         myform.add(new RadioGroup("colors", new PropertyModel(this,
>> "color"))
>>                 .add(new ListView<String>("color", colors) {
>>             @Override
>>             protected void populateItem(ListItem<String> item) {
>>                 item.add(new Radio("radio", item.getModel()))
>>                         .add(new Label("value", item.getModelObject()));
>>             }
>>         }));
>>         add(myform);
>>     }
>>
>>     public String getColor() {
>>         return color;
>>     }
>>     public void setColor(String color) {
>>         this.color = color;
>>     }
>>     public Date getDate() {
>>         return date;
>>     }
>>     public void setDate(Date date) {
>>         this.date = date;
>>     }
>> }
>>
>> ==TestPage.html==
>> <html>
>>     <head>
>>         <title></title>
>>     </head>
>>     <body>
>>         <form wicket:id="myform">
>>             <input type="submit"/>
>>             <wicket:container wicket:id="feedback"/>
>>             <input type="text" wicket:id="date"/><br/>
>>             <wicket:container wicket:id="colors">
>>                 <table>
>>                     <tr wicket:id="color">
>>                         <td><input type="radio" wicket:id="radio"/></td>
>>                         <td wicket:id="value"></td>
>>                     </tr>
>>                 </table>
>>             </wicket:container>
>>         </form>
>>     </body>
>> </html>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/RadioGroup-lost-value-after-onError-form-tp22718553p22777319.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RadioGroup lost value after onError form

Posted by Marieke Vandamme <ma...@tvh.be>.
Hello, 

Can't anyone help me with this? 
Or do I just report a jira bug for this? 
THANKS!


Marieke Vandamme wrote:
> 
> Hello, 
> 
> consider example underneath. 
> Form with DateTextField and RadioGroup. When an incorrect date is entered
> in the TextField, the value choosen in radiogroup is lost. When correct
> date is entered, the value is shown correct in radiogroup.
> Is this an error in my code? Or a bug?
> I'm using wicket 1.4-rc2. 
> Thanks for any help !!
> 
> ==TestPage.java==
> public class TestPage extends WebPage {
>     private String color;
>     private Date date;
>     public TestPage(){
>         Form myform = new Form("myform");
>         myform.add(new FeedbackPanel("feedback"));
>         myform.add(new DateTextField("date", new PropertyModel(this,
> "date")));
>         List<String> colors = Arrays.asList(new String[]{"green", "red",
> "yellow"});
>         myform.add(new RadioGroup("colors", new PropertyModel(this,
> "color"))
>                 .add(new ListView<String>("color", colors) {
>             @Override
>             protected void populateItem(ListItem<String> item) {
>                 item.add(new Radio("radio", item.getModel()))
>                         .add(new Label("value", item.getModelObject()));
>             }
>         }));
>         add(myform);
>     }
> 
>     public String getColor() {
>         return color;
>     }
>     public void setColor(String color) {
>         this.color = color;
>     }
>     public Date getDate() {
>         return date;
>     }
>     public void setDate(Date date) {
>         this.date = date;
>     }
> }
> 
> ==TestPage.html==
> <html>
>     <head>
>         <title></title>
>     </head>
>     <body>
>         <form wicket:id="myform">
>             <input type="submit"/>
>             <wicket:container wicket:id="feedback"/>
>             <input type="text" wicket:id="date"/><br/>
>             <wicket:container wicket:id="colors">
>                 <table>
>                     <tr wicket:id="color">
>                         <td><input type="radio" wicket:id="radio"/></td>
>                         <td wicket:id="value"></td>
>                     </tr>
>                 </table>
>             </wicket:container>
>         </form>
>     </body>
> </html>
> 
> 

-- 
View this message in context: http://www.nabble.com/RadioGroup-lost-value-after-onError-form-tp22718553p22777319.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org