ListView inside Form: retrieving the listview's model

2009-08-09 Thread Marcel Bonnet
Hi everybody, I'm new in the mail-list. I've been studying the framework, I
even read the book Wicket in Action, but I'm having trouble using some kind
of repeater inside a Form, updating and validating the model.
What I'm trying to do is a ListView inside a Form: when the user change the
value of the dropdownchoice, it needs to fire a validator to verify if the
new choice is already in the list. If it is, the validator must call the
"error(validatable)" method from AbstractValidator because I don't want
repeated choices in the list.
First question, anybody knows a simple way to do this?
Second, if I'm on the right way with the code above, how can I get the
listview's model (with the updated values changed by the user, instead of
the default items rendered on the view on the first time) so I can pass this
updated model to my Validator (it needs to know the values in the list to
know wich is repeated).

I just supressed the part of the code that fires my feedback message ( a
kind of Label because I don't want a message per component, just a global
message)
Thanks for any help. Marcel.

private class InputForm extends Form
{
// holds NameWrapper elements
private List data;

public InputForm(String name, IFeedback feedback)
{
super(name);

final SubmitLink update = new SubmitLink("update");
add(update);

// add some dummy data
data = new ArrayList();
data.add(new NameWrapper("one", 1, "default = 1", true));
data.add(new NameWrapper("two", 2, "default = 2", false));
data.add(new NameWrapper("three", 3, "default = 3", false));
data.add(new NameWrapper("four", 4, "default = 4", true));
 final Model dataModel = new Model();
dataModel.setObject(data);
ListView listView = new ListView("list", dataModel)
{

protected void populateItem(ListItem item)
{

NameWrapper wrapper = (NameWrapper)item.getModelObject();

item.add(new Label("name", wrapper.getName()));
item.add(new CheckBox("check", new
PropertyModel(wrapper, "selected")));

DropDownChoice combo = new DropDownChoice("combo"
, new Model(wrapper)
, new ArrayList(Arrays.asList(new
NameWrapper(1000,"mil"), new NameWrapper(2000,"dois mil"), new
NameWrapper(3000,"três mil")))
, new ChoiceRenderer("comboText","comboId"));

combo.add(new
NameWrapperValidator((List)dataModel.getObject()));
item.add(combo);
}
};
*listView.setReuseItems(true); *//i read this line
is very important
add(listView);


Re: ListView inside Form: retrieving the listview's model

2009-08-12 Thread Marcel Bonnet
Thanks for helping.
In fact I was trying to validate the ListView's model. I thought that each
time we press the Submit button the new choice selected in each
DropDownChoice in the ListView's rows would be submited and filled inside
the Model of the ListView, meaning the model would now have the new values
selected by the user. So I was trying to validate it's Model, because I want
to find a way to tell the user if he selected the same choice twice or more.
Each row of the ListView has a DropDownChoice but the form must not accept
repeated choices.
Now I'm not sure if the model would be updated or not...
I had succes writing such repeater with a validator like this using
RefreshingView instead of ListView. As I experienced, the model of the
RefreshingView was updated when the for was submited, but only with
TextField or CheckBox. When I changed the TextField by a DropwDownChoice, it
just not worked, so I started working around with a ListView, but I'm having
problems too.
Any ideas, please for validating repeated choices inside a repeater?


2009/8/11 bferr 

>
> The model of your listView has to be LoadableDetachable so that the
> listView
> retrieves the new list values each time.   Also the setReuseItems() might
> have to be false.   I don't think you're doing form validation within the
> ListView correct?
>
>
>
>
>
> Marcel Bonnet wrote:
> >
> > Hi everybody, I'm new in the mail-list. I've been studying the framework,
> > I
> > even read the book Wicket in Action, but I'm having trouble using some
> > kind
> > of repeater inside a Form, updating and validating the model.
> > What I'm trying to do is a ListView inside a Form: when the user change
> > the
> > value of the dropdownchoice, it needs to fire a validator to verify if
> the
> > new choice is already in the list. If it is, the validator must call the
> > "error(validatable)" method from AbstractValidator because I don't want
> > repeated choices in the list.
> > First question, anybody knows a simple way to do this?
> > Second, if I'm on the right way with the code above, how can I get the
> > listview's model (with the updated values changed by the user, instead of
> > the default items rendered on the view on the first time) so I can pass
> > this
> > updated model to my Validator (it needs to know the values in the list to
> > know wich is repeated).
> >
> > I just supressed the part of the code that fires my feedback message ( a
> > kind of Label because I don't want a message per component, just a global
> > message)
> > Thanks for any help. Marcel.
> >
> > private class InputForm extends Form
> > {
> > // holds NameWrapper elements
> > private List data;
> >
> > public InputForm(String name, IFeedback feedback)
> > {
> > super(name);
> >
> > final SubmitLink update = new SubmitLink("update");
> > add(update);
> >
> > // add some dummy data
> > data = new ArrayList();
> > data.add(new NameWrapper("one", 1, "default = 1", true));
> > data.add(new NameWrapper("two", 2, "default = 2", false));
> > data.add(new NameWrapper("three", 3, "default = 3", false));
> > data.add(new NameWrapper("four", 4, "default = 4", true));
> >  final Model dataModel = new Model();
> > dataModel.setObject(data);
> > ListView listView = new ListView("list", dataModel)
> > {
> >
> > protected void populateItem(ListItem item)
> > {
> >
> > NameWrapper wrapper =
> > (NameWrapper)item.getModelObject();
> >
> > item.add(new Label("name", wrapper.getName()));
> > item.add(new CheckBox("check", new
> > PropertyModel(wrapper, "selected")));
> >
> > DropDownChoice combo = new DropDownChoice("combo"
> > , new Model(wrapper)
> > , new ArrayList(Arrays.asList(new
> > NameWrapper(1000,"mil"), new NameWrapper(2000,"dois mil"), new
> > NameWrapper(3000,"três mil")))
> > , new ChoiceRenderer("comboText","comboId"));
> >
> > combo.add(new
> > NameWrapperValidator((List)dataModel.getObject()));
> > item.add(combo);
> > }
> > };
> > *listView.setReuseItems(true); *//i read this
> line
> > is very important
> > add(listView);
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/ListView-inside-Form%3A-retrieving-the-listview%27s-model-tp24893789p24922802.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: ListView inside Form: retrieving the listview's model

2009-08-12 Thread Marcel Bonnet
*SOLVED*.

I found what was wrong.
In case anyone needs a component like this, the main updated code is:

final Model dataModel = new Model();
dataModel.setObject(data);

ListView listView = new ListView("list", dataModel)
{

protected void populateItem(ListItem item)
{
final IModel model = item.getModel();

NameWrapper comboItem /*a kind of temp object for the
DropDownChoice:*/
= new
NameWrapper(((NameWrapper)model.getObject()).getComboId(),((NameWrapper)model.getObject()).getComboText());
final DropDownChoice combo = new DropDownChoice("combo"
, new Model(comboItem)
, CHOICES /* a list of possible choices
*/
, new
ChoiceRenderer("comboText","comboId"));

combo.add(new NameWrapperValidator(data));//data: the ListView's
object model. It will be iterated in my validator and call the
"error(validatable)" if there is more than one item of the current item. One
choice can be present only once in the whole list.
combo.add(new
AjaxFormComponentUpdatingBehavior("onchange"){
@Override
protected void onUpdate(AjaxRequestTarget
target) {
//the temp object will update the ListView's
Model (object named "data")

((NameWrapper)model.getObject()).setComboId(((NameWrapper)combo.getModelObject()).getComboId());

((NameWrapper)model.getObject()).setComboText(((NameWrapper)combo.getModelObject()).getComboText());
}
});
item.add(combo);

};
listView.setReuseItems(true);//so the list won't loose the new itens
add(listView);


>> --
>> View this message in context:
>> http://www.nabble.com/ListView-inside-Form%3A-retrieving-the-listview%27s-model-tp24893789p24922802.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>


Re: Need Wicket Book

2009-08-18 Thread Marcel Bonnet
Wicket in Action is really good, but it doesn't go too depper. I read a lot
and still having problems, so I recommend some of the links suggested and:
reading this mail-list (of course), the wiki http://cwiki.apache.org/WICKET/
and http://wicketstuff.org/ .
And I agree with Ernesto. IMO it's very expensive for us, in other
countries, to buy a book considering we pay in dollars (at least 2 times
more than a national book). For other things we can pay up to 60% of taxes,
over the price, for the government - not for books for while, but it still
expensive for a lot of stuff and a lot of people. That's why I recommended
the links.

2009/8/18 Ernesto Reinaldo Barreiro 

> Thanks for the pointer! I'll start reading right now!
> In fact, I do own a copy of the book. I just wanted to point out that NOT
> EVERYONE can afford buying a book!
>
> Ernesto
>
>
> On Tue, Aug 18, 2009 at 7:31 PM, Luther Baker 
> wrote:
>
> > If you can read quickly, the book is free for 14 days:
> >
> > http://my.safaribooksonline.com/9781932394986
> >
> > -Luther
> >
> >
> > On Tue, Aug 18, 2009 at 11:14 AM, Eelco Hillenius <
> > eelco.hillen...@gmail.com
> > > wrote:
> >
> > > On Mon, Aug 17, 2009 at 11:45 PM, Ernesto Reinaldo
> > > Barreiro wrote:
> > > > Well, expensive is a relative term: in the country I come from $27.50
> > is
> > > > almost twice the money a developer will receive as payment for a
> month
> > of
> > > > hard work;-)
> > >
> > > Insane, isn't it. Yet in other countries one wouldn't even accept that
> > > as an hourly wage.
> > >
> > > > Besides that, IMHO, the book is an excellent reading and buying it is
> a
> > > good
> > > > way to support those who expend so much energy and time maintaining
> the
> > > > framework.
> > >
> > > Glad to hear people are still liking the book. I wish prices would be
> > > distributed more to relative income, but that's out of my control :-)
> > >
> > > Anyway, I still feel that the examples project are an excellent source
> > > for learning about Wicket. Most important things are covered, and
> > > going through the examples is very hands-on. Also, you can download
> > > the first chapter of Wicket In Action for free, which will at least
> > > inform you what kind of problems the framework tries to solve.
> > >
> > > Good luck,
> > >
> > > Eelco
> > >
> > > Eelco
> > >
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
>


Re: Need Wicket Book

2009-08-18 Thread Marcel Bonnet
2009/8/18 Michael Mosmann 
>
> Am Dienstag, den 18.08.2009, 15:32 -0300 schrieb Marcel Bonnet:
> > Wicket in Action is really good, but it doesn't go too depper.
>
> If you have some questions, just ask.
>
> I would say: "visit my blog", but's only in german...
> (http://www.wicket-praxis.de/blog/) I also wrote a book about wicket
> (http://www.hanser.de/buch.asp?isbn=3-446-41909-8&area=Computer (but
> only in german language))
>
> .. so back to my first point: If you have some questions about wicket,
> which go deeper, then feel free to ask.

I don't know germany yet, but thanks anyway!

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



Re: Need Wicket Book

2009-08-18 Thread Marcel Bonnet
2009/8/18 Ernesto Reinaldo Barreiro :
> Or try to  the questions yourself! Wicket is OpenSource and the source is
> the best documentation you can ask for;-)

You're right, that's why I started to acess the SVN and read the code.
What I wanted was clarify that the book is good, but don't go to
deeper (because when we start, like the guy that asked for help, we
believe the book is a complete salvation!). So, the SVN is a second
recommendation (http://svn.apache.org/repos/asf/wicket/trunk).

>
> Ernesto
>
> On Tue, Aug 18, 2009 at 8:56 PM, Michael Mosmann  wrote:
>
>> Am Dienstag, den 18.08.2009, 15:32 -0300 schrieb Marcel Bonnet:
>> > Wicket in Action is really good, but it doesn't go too depper.
>>
>> If you have some questions, just ask.
>>
>> I would say: "visit my blog", but's only in german...
>> (http://www.wicket-praxis.de/blog/) I also wrote a book about wicket
>> (http://www.hanser.de/buch.asp?isbn=3-446-41909-8&area=Computer (but
>> only in german language))
>>
>> .. so back to my first point: If you have some questions about wicket,
>> which go deeper, then feel free to ask.
>>
>> michael mosmann
>>
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>

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