Re: property model question

2011-07-20 Thread Per Newgro

Am 20.07.2011 19:38, schrieb wmike1...@gmail.com:

In the wicket example of Form Input (
http://wicketstuff.org/wicket14/forminput/
http://wicketstuff.org/wicket14/forminput/ ), I'm looking at the source and
can't make out what's happening with this line:

 // display the multiply result
 Label multiplyLabel = new Label("multiplyLabel", new
PropertyModel(
 getDefaultModel(), "multiply"));

I understand what this accomplishes, but I don't understand how. We're
passing this property model the default model of what exactly? I don't get
what it means to pass a property model a sublass of IModel to base itself
off of.

Thanks,
mike

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/property-model-question-tp3681616p3681616.html
Sent from the Users forum 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


The property model is set formerly to the parent container (form or 
panel) by constructor injection.

new Form("id", defaultModel);
or
new Panel("id", defaultModel);

If you check the hierachy of parent classes you can see the 
getDefaultModel mthod implementation.


Cheers
Per

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



Re: property model question

2011-07-20 Thread Igor Vaynberg
this is called model chaining. where models know that their model
object is another model and can properly handle it.

in this particular example

imodel d=getdefaultmodel()
imodel p=new propertymodel(d, "multiply")

p.getobject() then does this

object target=mytarget; (in this case d)
while (target instanceof imodel) { target=imodel.getobject(); }
getproperty(target, property);

so in execution p.getobject() resolves to this: d.getobject().getmultiply();

makes sense?

-igor



On Wed, Jul 20, 2011 at 10:38 AM, wmike1...@gmail.com
 wrote:
> In the wicket example of Form Input (
> http://wicketstuff.org/wicket14/forminput/
> http://wicketstuff.org/wicket14/forminput/ ), I'm looking at the source and
> can't make out what's happening with this line:
>
>            // display the multiply result
>            Label multiplyLabel = new Label("multiplyLabel", new
> PropertyModel(
>                getDefaultModel(), "multiply"));
>
> I understand what this accomplishes, but I don't understand how. We're
> passing this property model the default model of what exactly? I don't get
> what it means to pass a property model a sublass of IModel to base itself
> off of.
>
> Thanks,
> mike
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/property-model-question-tp3681616p3681616.html
> Sent from the Users forum 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
>
>

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



property model question

2011-07-20 Thread wmike1...@gmail.com
In the wicket example of Form Input (
http://wicketstuff.org/wicket14/forminput/
http://wicketstuff.org/wicket14/forminput/ ), I'm looking at the source and
can't make out what's happening with this line:

// display the multiply result
Label multiplyLabel = new Label("multiplyLabel", new
PropertyModel(
getDefaultModel(), "multiply"));

I understand what this accomplishes, but I don't understand how. We're
passing this property model the default model of what exactly? I don't get
what it means to pass a property model a sublass of IModel to base itself
off of.

Thanks,
mike

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/property-model-question-tp3681616p3681616.html
Sent from the Users forum 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: quick page model question

2011-01-04 Thread Jeremy Thomerson
On Tue, Jan 4, 2011 at 2:10 PM, gnugrf  wrote:

>
> Thanks a million man!
>
> I wasn't calling super(model) and after figuring out how to attach sources
> (which I hadn't known about), I was able to see that the page model was
> being detached and refreshed.


Great!


> The labels on the page aren't updating, but
> I'm assuming I need to provide each component with dynamic models e.g
> propertymodels referencing the page model.
>

Yes.


> You saved me weeks of searching and I can't tell you how much I appreciate
> the time you took helping me.
>

No worries.   Glad it worked out.

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*


Re: quick page model question

2011-01-04 Thread gnugrf

Thanks a million man!

I wasn't calling super(model) and after figuring out how to attach sources
(which I hadn't known about), I was able to see that the page model was
being detached and refreshed. The labels on the page aren't updating, but
I'm assuming I need to provide each component with dynamic models e.g
propertymodels referencing the page model. 

You saved me weeks of searching and I can't tell you how much I appreciate
the time you took helping me. 
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/quick-page-model-question-tp3172678p3174289.html
Sent from the Users forum 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: quick page model question

2011-01-04 Thread Jeremy Thomerson
On Tue, Jan 4, 2011 at 10:28 AM, gnugrf  wrote:

>
> Jeremy thanks for your patience, I have a couple of questions about your
> replies.
>
> 1. If my constructors for the page are
> public ManageClientPage(long id){this(new ClientLDM(id));}
>public ManageClientPage(IModel client) { ///code here}
>
> and the page is being called using ... ManageclientPage(clientId) isn't the
> second constructor setting the page model? Previously I was making an
> explicit call to setDefaultModel(), but it seemed to have the same
> functionality, and I thought setting the model through the constructor
> seemed cleaner.
>

Only if you are calling super(model) within that constructor.

2. How do I set a breakpoint on a method inherited from an abstract class? I
> would assume setting it on the detach method in the abstract class. Isnt
> this going to make execution stop every time ANY ldm detaches?
>

If you open the Wicket source (hopefully you have it attached to your IDE),
you can set the breakpoint in LDM's detach.  As you mention, this will make
it stop for EVERY LDM.  But, if you only have a couple on the page, no big
deal.  If you have a lot, override onDetach in your custom model and put the
breakpoint there.


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*


Re: quick page model question

2011-01-04 Thread gnugrf

Jeremy thanks for your patience, I have a couple of questions about your
replies. 

1. If my constructors for the page are 
public ManageClientPage(long id){this(new ClientLDM(id));}
public ManageClientPage(IModel client) { ///code here} 

and the page is being called using ... ManageclientPage(clientId) isn't the
second constructor setting the page model? Previously I was making an
explicit call to setDefaultModel(), but it seemed to have the same
functionality, and I thought setting the model through the constructor
seemed cleaner.

2. How do I set a breakpoint on a method inherited from an abstract class? I
would assume setting it on the detach method in the abstract class. Isnt
this going to make execution stop every time ANY ldm detaches?




-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/quick-page-model-question-tp3172678p3173857.html
Sent from the Users forum 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: quick page model question

2011-01-04 Thread Jeremy Thomerson
On Tue, Jan 4, 2011 at 9:18 AM, gnugrf  wrote:
>
> I set a breakpoint within the load() and when the page first gets constructed
> I am able to watch the code get executed. When I refresh, the listview on
> the page (which uses a different LDM) does get called again, however this
> LDM (the model for the page) does not.
>
> I think I probably copied most of this from the examples I've found. I read
> detach happens automatically and that I didn't need to override it, is that
> true?

Detach happens automatically if your model is used as the default
model in any component in your page hierarchy.  So, if this is your
page model, it should be detached automatically.  Put a breakpoint in
LDM detach to verify.

> public class ClientLDM extends LoadableDetachableModel
> {
>   �...@springbean
>    ClientService clientService;
>
>    private final long id;
>
>    public ClientLDM(Client c){this(c.getId());}
>
>    public ClientLDM(long id){
>
>        InjectorHolder.getInjector().inject(this);
>        if (id == 0)
>        {
>            throw new IllegalArgumentException();

I know this isn't related to your question, but you should always
throw useful exceptions - with a useful (to the developer) message.

>        }
>        this.id = id;
>    }
>
>   �...@override
>    public int hashCode()
>    {
>        return Long.valueOf(id).hashCode();
>    }
>
>   �...@override
>    public boolean equals(final Object obj)
>    {
>        if (obj == this)
>        {
>            return true;
>        }
>        else if (obj == null)
>        {
>            return false;
>        }
>        else if (obj instanceof ClientLDM)
>        {
>            ClientLDM other = (ClientLDM)obj;
>            return other.id == id;
>        }
>        return false;
>    }
>
>   �...@override
>    protected Client load()
>    {
>
>        Client client = new Client();
>        try {
>          client = clientService.loadClient("web", id);
>        } catch (InvalidClientException e) {
>        e.printStackTrace();
>        }
>        return client;
>    }
>
>
> }

See what the breakpoint in detach tells you.  Make sure you're using
the model as the default model in some component.  Then send us the
entire code for your page if you can't figure it out.

-- 
Jeremy Thomerson
http://wickettraining.com
Need a CMS for Wicket?  Use Brix! http://brixcms.org

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



Re: quick page model question

2011-01-04 Thread gnugrf

I set a breakpoint within the load() and when the page first gets constructed
I am able to watch the code get executed. When I refresh, the listview on
the page (which uses a different LDM) does get called again, however this
LDM (the model for the page) does not.

I think I probably copied most of this from the examples I've found. I read
detach happens automatically and that I didn't need to override it, is that
true?

public class ClientLDM extends LoadableDetachableModel
{
@SpringBean
ClientService clientService;

private final long id;

public ClientLDM(Client c){this(c.getId());}

public ClientLDM(long id){

InjectorHolder.getInjector().inject(this);
if (id == 0)
{
throw new IllegalArgumentException();
}
this.id = id;
}

@Override
public int hashCode()
{
return Long.valueOf(id).hashCode();
}

@Override
public boolean equals(final Object obj)
{
if (obj == this)
{
return true;
}
else if (obj == null)
{
return false;
}
else if (obj instanceof ClientLDM)
{
ClientLDM other = (ClientLDM)obj;
return other.id == id;
}
return false;
}

@Override
protected Client load()
{

Client client = new Client();
try {
  client = clientService.loadClient("web", id);
} catch (InvalidClientException e) {
e.printStackTrace();
}
return client;
}


}
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/quick-page-model-question-tp3172678p3173721.html
Sent from the Users forum 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: quick page model question

2011-01-03 Thread Jeremy Thomerson
On Mon, Jan 3, 2011 at 5:00 PM, gnugrf  wrote:
>
> I'm pretty much a noob, even though I've been slowly working on a project for
> about a year so bear with me. I've read "understanding models" a couple
> dozen times already and lifecycle, requestcycle, etc. and did a fair amount
> of slogging through the mailing list for old posts about "page resfresh"
> "page model", etc. and didnt find anything to help me, so forgive my
> stupidity..
>
> How would i refresh it in the loadabledetachable model (how would the model
> know when the page has been refreshed)

In a LDM, load() will be called every time that getObject is called
*and* the object has not already been loaded.  There is a transient
instance field in LDM that holds the object once it is loaded.  At the
end of every request, detach() is called, which nulls out that
transient object reference.  This means that on the next page view
(new request), getObject will presumably be called by something that
is using your page model, and in turn, load() will be called again.
You don't have to do anything to "refresh" your model.

If that is not happening, please show the LDM code you have.

-- 
Jeremy Thomerson
http://wickettraining.com
Need a CMS for Wicket?  Use Brix! http://brixcms.org

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



Re: quick page model question

2011-01-03 Thread gnugrf

I'm pretty much a noob, even though I've been slowly working on a project for
about a year so bear with me. I've read "understanding models" a couple
dozen times already and lifecycle, requestcycle, etc. and did a fair amount
of slogging through the mailing list for old posts about "page resfresh"
"page model", etc. and didnt find anything to help me, so forgive my
stupidity..

How would i refresh it in the loadabledetachable model (how would the model
know when the page has been refreshed)

onbeforerender makes sense to me since its an event, i suppose you are
saying to override that method and i could force the page to reload the
model there. i saw in the javadocs it warned to call super.onbeforerender at
the end.

is there any advantage to either direction?

also as a sanity check my constructors are -->

public ManageClientPage(long id){this(new ClientLDM(id));}
public ManageClientPage(IModel client) { ///code here}

and its being called using id.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/quick-page-model-question-tp3172678p3172797.html
Sent from the Users forum 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: quick page model question

2011-01-03 Thread Martin Makundi
You can refresh it in your loadabledetachable model or
onbeforerender.. there are some alternatives.

**
Martin

2011/1/3 gnugrf :
>
> how do you get the page model to refresh when a user presses "reload" or F5?
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/quick-page-model-question-tp3172678p3172678.html
> Sent from the Users forum 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
>
>

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



quick page model question

2011-01-03 Thread gnugrf

how do you get the page model to refresh when a user presses "reload" or F5?
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/quick-page-model-question-tp3172678p3172678.html
Sent from the Users forum 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: Model question ?

2009-08-16 Thread Martijn Dashorst
Just don't pass the model to another page (also don't do this for
anon-inner classes, or nested classes that carry a this pointer to the
page)

Martijn

On Sun, Aug 16, 2009 at 4:04 AM, Warren Bell wrote:
> Is there any issues you need to be concerned with when using the page
> itself as the model object?
>
> Warren
>
> -Original Message-
> From: jWeekend [mailto:jweekend_for...@cabouge.com]
> Sent: Friday, August 14, 2009 5:43 PM
> To: users@wicket.apache.org
> Subject: RE: Model question ?
>
>
> Warren,
>
> If you don't mind your "wicket:id"s becoming rather misleading and
> arguably slightly harder to follow (magical) Java, you can even do ...
>
> public class HomePage extends WebPage {
>    private List vendors = Arrays.asList(new Vendor("v1"),
>            new Vendor("v2"));
>    private Vendor vendor = new Vendor("default vendor");
>    public HomePage(final PageParameters parameters) {
>        setDefaultModel(new CompoundPropertyModel(this));
>        Form form = new Form("form");
>        add(form);
>        form.add(new ListChoice("vendor", vendors));
>        Form editForm = new Form("vendorEditForm");
>        add(editForm);
>        editForm.add(new TextField("vendor.name"));
>    }
>    private class Vendor {
>        private String name;
>        Vendor(String name) {this.name = name;}
>       �...@override public String toString() {return name;}
>    }
> }
>
> I haven't worked out how to properly paste html into nabble, so drop me
> a line at the jWeekend site if you want the template code to go with
> this, or a QuickStart.
>
> Any comments on the type-parameters used above anybody?!
>
> Regards - Cemal
> jWeekend
> OO & Java Technologies, Wicket Training and Development
> http://jWeekend.com
>
>
> Warren Bell-3 wrote:
>>
>> In your second example the Vendor in the vendorModel becomes the
>> selected Vendor from the ListChoice and that Vendor name property
>> becomes the value of the TextField?
>>
>> -Original Message-
>> From: jWeekend [mailto:jweekend_for...@cabouge.com]
>> Sent: Friday, August 14, 2009 3:47 PM
>> To: users@wicket.apache.org
>> Subject: Re: Model question ?
>>
>>
>> Warren,
>>
>> ... and if you prefer using a CPM for your "vendorEditForm"s:
>>
>> public class HomePage extends WebPage {
>>     private List vendors = Arrays.asList(new Vendor("v1"),
>>                                                                  new
>> Vendor("v2"));
>>     private Vendor vendor = new Vendor("default vendor");
>>     public HomePage(final PageParameters parameters) {
>>         IModel vendorModel = new PropertyModel(this,
> "vendor");
>>         Form form = new Form("form");
>>         add(form);
>>         // use your existing LDM instead of this hard-wired
>>         // List of vendors but
>>         // make sure you merge your edits properly!
>>         form.add(new ListChoice("vendors",
>>                                          vendorModel, vendors));
>>         // using a PropertyModel per field
>>         Form editForm1 = new Form("vendorEditForm1");
>>         add(editForm1);
>>         editForm1.add(new TextField("name",
>>                 new PropertyModel(this, "vendor.name")));
>>         // using a CompoundPropertyModel
>>         Form editForm2 = new Form("vendorEditForm2",
>>                 new CompoundPropertyModel(vendorModel));
>>         add(editForm2);
>>         editForm2.add(new TextField("name"));
>>     }
>>
>>     private class Vendor implements Serializable{
>>         private String name;
>>         protected Vendor(String name) {this.name = name;}
>>         public String toString(){return name;}
>>         // safer to have accessors & mutators
>>     }
>>     // safer to have accessors & mutators }
>>
>> Regards - Cemal
>> jWeekend
>> OO & Java Technologies, Wicket Training and Development
>> http://jWeekend.com
>>
>>
>>
>> Warren Bell-3 wrote:
>>>
>>> How should I set up my model for the following situation. I have a
>>> form with a ListChoice and a TextField. The TextField needs to access
>
>>> a property of the object selected of the ListChoice. I have it all
>>> working using a ValueMap, but that seems like overkill to use a
>>> ValueMap for one obj

Re: Model question ?

2009-08-15 Thread Eelco Hillenius
> Is there any issues you need to be concerned with when using the page
> itself as the model object?

I don't think so.

Eelco

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



RE: Model question ?

2009-08-15 Thread Warren Bell
Is there any issues you need to be concerned with when using the page
itself as the model object?

Warren 

-Original Message-
From: jWeekend [mailto:jweekend_for...@cabouge.com] 
Sent: Friday, August 14, 2009 5:43 PM
To: users@wicket.apache.org
Subject: RE: Model question ?


Warren,

If you don't mind your "wicket:id"s becoming rather misleading and
arguably slightly harder to follow (magical) Java, you can even do ...

public class HomePage extends WebPage {
private List vendors = Arrays.asList(new Vendor("v1"), 
new Vendor("v2"));
private Vendor vendor = new Vendor("default vendor");
public HomePage(final PageParameters parameters) {
setDefaultModel(new CompoundPropertyModel(this));
Form form = new Form("form"); 
add(form); 
form.add(new ListChoice("vendor", vendors)); 
Form editForm = new Form("vendorEditForm");
add(editForm);
editForm.add(new TextField("vendor.name"));
}
private class Vendor {
private String name;
Vendor(String name) {this.name = name;}
@Override public String toString() {return name;}
}
}

I haven't worked out how to properly paste html into nabble, so drop me
a line at the jWeekend site if you want the template code to go with
this, or a QuickStart. 

Any comments on the type-parameters used above anybody?!

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket Training and Development
http://jWeekend.com


Warren Bell-3 wrote:
> 
> In your second example the Vendor in the vendorModel becomes the 
> selected Vendor from the ListChoice and that Vendor name property 
> becomes the value of the TextField?
> 
> -Original Message-
> From: jWeekend [mailto:jweekend_for...@cabouge.com]
> Sent: Friday, August 14, 2009 3:47 PM
> To: users@wicket.apache.org
> Subject: Re: Model question ?
> 
> 
> Warren,
> 
> ... and if you prefer using a CPM for your "vendorEditForm"s:
> 
> public class HomePage extends WebPage {
> private List vendors = Arrays.asList(new Vendor("v1"), 
>  new 
> Vendor("v2"));
> private Vendor vendor = new Vendor("default vendor");
> public HomePage(final PageParameters parameters) {
> IModel vendorModel = new PropertyModel(this,
"vendor");
> Form form = new Form("form");
> add(form);
> // use your existing LDM instead of this hard-wired 
> // List of vendors but 
> // make sure you merge your edits properly!
> form.add(new ListChoice("vendors", 
>  vendorModel, vendors));
> // using a PropertyModel per field
> Form editForm1 = new Form("vendorEditForm1");
> add(editForm1);
> editForm1.add(new TextField("name", 
> new PropertyModel(this, "vendor.name")));   
> // using a CompoundPropertyModel   
> Form editForm2 = new Form("vendorEditForm2", 
> new CompoundPropertyModel(vendorModel));
> add(editForm2);
> editForm2.add(new TextField("name")); 
> }
> 
> private class Vendor implements Serializable{
> private String name;
> protected Vendor(String name) {this.name = name;}
> public String toString(){return name;}
> // safer to have accessors & mutators
> }
> // safer to have accessors & mutators }
> 
> Regards - Cemal
> jWeekend
> OO & Java Technologies, Wicket Training and Development 
> http://jWeekend.com
> 
> 
> 
> Warren Bell-3 wrote:
>> 
>> How should I set up my model for the following situation. I have a 
>> form with a ListChoice and a TextField. The TextField needs to access

>> a property of the object selected of the ListChoice. I have it all 
>> working using a ValueMap, but that seems like overkill to use a 
>> ValueMap for one object. Here is how I have it:
>>  
>> super(new CompoundPropertyModel(new ValueMap()));
>> 
>> ListChoice vendorListChoice = new 
>> ListChoice("vendor",
> 
>> new LoadableDetachableModel>(){...}, new 
>> IChoiceRenderer(){...});
>> 
>> TextField accountNumberField = new 
>> TextField("vendor.accountNumber");
>> 
>> I thought I could do something like this:
>> 
>> super(new CompoundPropertyModel(new Vendor()));
>> 
>> The ListChoice is the same as above and the TextField like this:
>> 
>> TextField accountNumberField = new 
&

RE: Model question ?

2009-08-14 Thread jWeekend

Warren,

If you don't mind your "wicket:id"s becoming rather misleading and arguably
slightly harder to follow (magical) Java, you can even do ...

public class HomePage extends WebPage {
private List vendors = Arrays.asList(new Vendor("v1"), 
new Vendor("v2"));
private Vendor vendor = new Vendor("default vendor");
public HomePage(final PageParameters parameters) {
setDefaultModel(new CompoundPropertyModel(this));
Form form = new Form("form"); 
add(form); 
form.add(new ListChoice("vendor", vendors)); 
Form editForm = new Form("vendorEditForm");
add(editForm);
editForm.add(new TextField("vendor.name"));
}
private class Vendor {
private String name;
Vendor(String name) {this.name = name;}
@Override public String toString() {return name;}
}
}

I haven't worked out how to properly paste html into nabble, so drop me a
line at the jWeekend site if you want the template code to go with this, or
a QuickStart. 

Any comments on the type-parameters used above anybody?!

Regards - Cemal 
jWeekend 
OO & Java Technologies, Wicket Training and Development 
http://jWeekend.com


Warren Bell-3 wrote:
> 
> In your second example the Vendor in the vendorModel becomes the
> selected Vendor from the ListChoice and that Vendor name property
> becomes the value of the TextField? 
> 
> -Original Message-
> From: jWeekend [mailto:jweekend_for...@cabouge.com] 
> Sent: Friday, August 14, 2009 3:47 PM
> To: users@wicket.apache.org
> Subject: Re: Model question ?
> 
> 
> Warren,
> 
> ... and if you prefer using a CPM for your "vendorEditForm"s:
> 
> public class HomePage extends WebPage {
> private List vendors = Arrays.asList(new Vendor("v1"), 
>  new
> Vendor("v2"));
> private Vendor vendor = new Vendor("default vendor");
> public HomePage(final PageParameters parameters) {
> IModel vendorModel = new PropertyModel(this, "vendor");
> Form form = new Form("form");
> add(form);
> // use your existing LDM instead of this hard-wired 
> // List of vendors but 
> // make sure you merge your edits properly!
> form.add(new ListChoice("vendors", 
>  vendorModel, vendors));
> // using a PropertyModel per field
> Form editForm1 = new Form("vendorEditForm1");
> add(editForm1);
> editForm1.add(new TextField("name", 
> new PropertyModel(this, "vendor.name")));   
> // using a CompoundPropertyModel   
> Form editForm2 = new Form("vendorEditForm2", 
> new CompoundPropertyModel(vendorModel));
> add(editForm2);
> editForm2.add(new TextField("name")); 
> }
> 
> private class Vendor implements Serializable{
> private String name;
> protected Vendor(String name) {this.name = name;}
> public String toString(){return name;}
> // safer to have accessors & mutators
> }
> // safer to have accessors & mutators }
> 
> Regards - Cemal
> jWeekend
> OO & Java Technologies, Wicket Training and Development
> http://jWeekend.com
> 
> 
> 
> Warren Bell-3 wrote:
>> 
>> How should I set up my model for the following situation. I have a 
>> form with a ListChoice and a TextField. The TextField needs to access 
>> a property of the object selected of the ListChoice. I have it all 
>> working using a ValueMap, but that seems like overkill to use a 
>> ValueMap for one object. Here is how I have it:
>>  
>> super(new CompoundPropertyModel(new ValueMap()));
>> 
>> ListChoice vendorListChoice = new ListChoice("vendor",
> 
>> new LoadableDetachableModel>(){...}, new 
>> IChoiceRenderer(){...});
>> 
>> TextField accountNumberField = new 
>> TextField("vendor.accountNumber");
>> 
>> I thought I could do something like this:
>> 
>> super(new CompoundPropertyModel(new Vendor()));
>> 
>> The ListChoice is the same as above and the TextField like this:
>> 
>> TextField accountNumberField = new 
>> TextField("accountNumber");
>> 
>> The problem with this is that the ListChoice is trying to set a 
>> property on the model named vendor when I realy want the selected 
>> ListChoice vendor object be the model object and have the TextFie

RE: Model question ?

2009-08-14 Thread jWeekend

Warren,

Exactly - and in a very Wicket way! 

Just drop the code into your IDE and run it - if there are no typos (other
than the type parameter to the TextFields - the compiler can't help you
here!) it just works.

Regards - Cemal 
jWeekend 
OO & Java Technologies, Wicket Training and Development 
http://jWeekend.com




Warren Bell-3 wrote:
> 
> In your second example the Vendor in the vendorModel becomes the
> selected Vendor from the ListChoice and that Vendor name property
> becomes the value of the TextField? 
> 
> -Original Message-
> From: jWeekend [mailto:jweekend_for...@cabouge.com] 
> Sent: Friday, August 14, 2009 3:47 PM
> To: users@wicket.apache.org
> Subject: Re: Model question ?
> 
> 
> Warren,
> 
> ... and if you prefer using a CPM for your "vendorEditForm"s:
> 
> public class HomePage extends WebPage {
> private List vendors = Arrays.asList(new Vendor("v1"), 
>  new
> Vendor("v2"));
> private Vendor vendor = new Vendor("default vendor");
> public HomePage(final PageParameters parameters) {
> IModel vendorModel = new PropertyModel(this, "vendor");
> Form form = new Form("form");
> add(form);
> // use your existing LDM instead of this hard-wired 
> // List of vendors but 
> // make sure you merge your edits properly!
> form.add(new ListChoice("vendors", 
>  vendorModel, vendors));
> // using a PropertyModel per field
> Form editForm1 = new Form("vendorEditForm1");
> add(editForm1);
> editForm1.add(new TextField("name", 
> new PropertyModel(this, "vendor.name")));   
> // using a CompoundPropertyModel   
> Form editForm2 = new Form("vendorEditForm2", 
> new CompoundPropertyModel(vendorModel));
> add(editForm2);
> editForm2.add(new TextField("name")); 
> }
> 
> private class Vendor implements Serializable{
> private String name;
> protected Vendor(String name) {this.name = name;}
> public String toString(){return name;}
> // safer to have accessors & mutators
> }
> // safer to have accessors & mutators }
> 
> Regards - Cemal
> jWeekend
> OO & Java Technologies, Wicket Training and Development
> http://jWeekend.com
> 
> 
> 
> Warren Bell-3 wrote:
>> 
>> How should I set up my model for the following situation. I have a 
>> form with a ListChoice and a TextField. The TextField needs to access 
>> a property of the object selected of the ListChoice. I have it all 
>> working using a ValueMap, but that seems like overkill to use a 
>> ValueMap for one object. Here is how I have it:
>>  
>> super(new CompoundPropertyModel(new ValueMap()));
>> 
>> ListChoice vendorListChoice = new ListChoice("vendor",
> 
>> new LoadableDetachableModel>(){...}, new 
>> IChoiceRenderer(){...});
>> 
>> TextField accountNumberField = new 
>> TextField("vendor.accountNumber");
>> 
>> I thought I could do something like this:
>> 
>> super(new CompoundPropertyModel(new Vendor()));
>> 
>> The ListChoice is the same as above and the TextField like this:
>> 
>> TextField accountNumberField = new 
>> TextField("accountNumber");
>> 
>> The problem with this is that the ListChoice is trying to set a 
>> property on the model named vendor when I realy want the selected 
>> ListChoice vendor object be the model object and have the TextField 
>> access the accountNumber property of the ListChoice vendor.
>> 
>> How should I set up my model to deal with this type of situation or is
> 
>> a ValueMap the best way?
>> 
>> Thanks,
>> 
>> Warren
>> 
>> 
>> 
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/Model-question---tp24978225p24979787.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
> 
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Model-question---tp24978225p24980016.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: Model question ?

2009-08-14 Thread Warren Bell
In your second example the Vendor in the vendorModel becomes the
selected Vendor from the ListChoice and that Vendor name property
becomes the value of the TextField? 

-Original Message-
From: jWeekend [mailto:jweekend_for...@cabouge.com] 
Sent: Friday, August 14, 2009 3:47 PM
To: users@wicket.apache.org
Subject: Re: Model question ?


Warren,

... and if you prefer using a CPM for your "vendorEditForm"s:

public class HomePage extends WebPage {
private List vendors = Arrays.asList(new Vendor("v1"), 
 new
Vendor("v2"));
private Vendor vendor = new Vendor("default vendor");
public HomePage(final PageParameters parameters) {
IModel vendorModel = new PropertyModel(this, "vendor");
Form form = new Form("form");
add(form);
// use your existing LDM instead of this hard-wired 
// List of vendors but 
// make sure you merge your edits properly!
form.add(new ListChoice("vendors", 
 vendorModel, vendors));
// using a PropertyModel per field
Form editForm1 = new Form("vendorEditForm1");
add(editForm1);
editForm1.add(new TextField("name", 
new PropertyModel(this, "vendor.name")));   
// using a CompoundPropertyModel   
Form editForm2 = new Form("vendorEditForm2", 
new CompoundPropertyModel(vendorModel));
add(editForm2);
editForm2.add(new TextField("name")); 
}

private class Vendor implements Serializable{
private String name;
protected Vendor(String name) {this.name = name;}
public String toString(){return name;}
// safer to have accessors & mutators
}
// safer to have accessors & mutators }

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket Training and Development
http://jWeekend.com



Warren Bell-3 wrote:
> 
> How should I set up my model for the following situation. I have a 
> form with a ListChoice and a TextField. The TextField needs to access 
> a property of the object selected of the ListChoice. I have it all 
> working using a ValueMap, but that seems like overkill to use a 
> ValueMap for one object. Here is how I have it:
>  
> super(new CompoundPropertyModel(new ValueMap()));
> 
> ListChoice vendorListChoice = new ListChoice("vendor",

> new LoadableDetachableModel>(){...}, new 
> IChoiceRenderer(){...});
> 
> TextField accountNumberField = new 
> TextField("vendor.accountNumber");
> 
> I thought I could do something like this:
> 
> super(new CompoundPropertyModel(new Vendor()));
> 
> The ListChoice is the same as above and the TextField like this:
> 
> TextField accountNumberField = new 
> TextField("accountNumber");
> 
> The problem with this is that the ListChoice is trying to set a 
> property on the model named vendor when I realy want the selected 
> ListChoice vendor object be the model object and have the TextField 
> access the accountNumber property of the ListChoice vendor.
> 
> How should I set up my model to deal with this type of situation or is

> a ValueMap the best way?
> 
> Thanks,
> 
> Warren
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

--
View this message in context:
http://www.nabble.com/Model-question---tp24978225p24979787.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



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



Re: Model question ?

2009-08-14 Thread jWeekend

Warren,

... and if you prefer using a CPM for your "vendorEditForm"s:

public class HomePage extends WebPage {
private List vendors = Arrays.asList(new Vendor("v1"), 
 new
Vendor("v2"));
private Vendor vendor = new Vendor("default vendor");
public HomePage(final PageParameters parameters) {
IModel vendorModel = new PropertyModel(this, "vendor");
Form form = new Form("form");
add(form);
// use your existing LDM instead of this hard-wired 
// List of vendors but 
// make sure you merge your edits properly!
form.add(new ListChoice("vendors", 
 vendorModel, vendors));
// using a PropertyModel per field
Form editForm1 = new Form("vendorEditForm1");
add(editForm1);
editForm1.add(new TextField("name", 
new PropertyModel(this, "vendor.name")));   
// using a CompoundPropertyModel   
Form editForm2 = new Form("vendorEditForm2", 
new CompoundPropertyModel(vendorModel));
add(editForm2);
editForm2.add(new TextField("name")); 
}

private class Vendor implements Serializable{
private String name;
protected Vendor(String name) {this.name = name;}
public String toString(){return name;}
// safer to have accessors & mutators
}
// safer to have accessors & mutators
}

Regards - Cemal 
jWeekend 
OO & Java Technologies, Wicket Training and Development 
http://jWeekend.com



Warren Bell-3 wrote:
> 
> How should I set up my model for the following situation. I have a form
> with a ListChoice and a TextField. The TextField needs to access a
> property of the object selected of the ListChoice. I have it all working
> using a ValueMap, but that seems like overkill to use a ValueMap for one
> object. Here is how I have it:
>  
> super(new CompoundPropertyModel(new ValueMap()));
> 
> ListChoice vendorListChoice = new ListChoice("vendor",
> new LoadableDetachableModel>(){...}, new
> IChoiceRenderer(){...});
> 
> TextField accountNumberField = new
> TextField("vendor.accountNumber");
> 
> I thought I could do something like this:
> 
> super(new CompoundPropertyModel(new Vendor()));
> 
> The ListChoice is the same as above and the TextField like this:
> 
> TextField accountNumberField = new
> TextField("accountNumber");
> 
> The problem with this is that the ListChoice is trying to set a property
> on the model named vendor when I realy want the selected ListChoice
> vendor object be the model object and have the TextField access the
> accountNumber property of the ListChoice vendor.
> 
> How should I set up my model to deal with this type of situation or is a
> ValueMap the best way?
> 
> Thanks,
> 
> Warren
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Model-question---tp24978225p24979787.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: Model question ?

2009-08-14 Thread jWeekend

Warren,

Something like this?

public class HomePage extends WebPage {
private List vendors = Arrays.asList(new Vendor("v1"), new
Vendor("v2"));
private Vendor vendor = new Vendor("default vendor");
public HomePage(final PageParameters parameters) {
Form form = new Form("form");
add(form);
// use your existing LDM instead of this hard-wired List of vendors
but
// make sure you merge your edits properly!
form.add(new ListChoice("vendors", new
PropertyModel(this, "vendor"), vendors));
Form editForm = new Form("vendorEditForm");
add(editForm);
editForm.add(new TextField("name", new
PropertyModel(this, "vendor.name")));  
}

private class Vendor implements Serializable{
private String name;
protected Vendor(String name) {this.name = name;}
public String toString(){return name;}
// safer to have accessors & mutators
}
// safer to have accessors & mutators
}

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket Training and Development
http://jWeekend.com



Warren Bell-3 wrote:
> 
> How should I set up my model for the following situation. I have a form
> with a ListChoice and a TextField. The TextField needs to access a
> property of the object selected of the ListChoice. I have it all working
> using a ValueMap, but that seems like overkill to use a ValueMap for one
> object. Here is how I have it:
>  
> super(new CompoundPropertyModel(new ValueMap()));
> 
> ListChoice vendorListChoice = new ListChoice("vendor",
> new LoadableDetachableModel>(){...}, new
> IChoiceRenderer(){...});
> 
> TextField accountNumberField = new
> TextField("vendor.accountNumber");
> 
> I thought I could do something like this:
> 
> super(new CompoundPropertyModel(new Vendor()));
> 
> The ListChoice is the same as above and the TextField like this:
> 
> TextField accountNumberField = new
> TextField("accountNumber");
> 
> The problem with this is that the ListChoice is trying to set a property
> on the model named vendor when I realy want the selected ListChoice
> vendor object be the model object and have the TextField access the
> accountNumber property of the ListChoice vendor.
> 
> How should I set up my model to deal with this type of situation or is a
> ValueMap the best way?
> 
> Thanks,
> 
> Warren
> 
> 
> 
> 
> -----
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Model-question---tp24978225p24979290.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



Model question ?

2009-08-14 Thread Warren Bell
How should I set up my model for the following situation. I have a form
with a ListChoice and a TextField. The TextField needs to access a
property of the object selected of the ListChoice. I have it all working
using a ValueMap, but that seems like overkill to use a ValueMap for one
object. Here is how I have it:
 
super(new CompoundPropertyModel(new ValueMap()));

ListChoice vendorListChoice = new ListChoice("vendor",
new LoadableDetachableModel>(){...}, new
IChoiceRenderer(){...});

TextField accountNumberField = new
TextField("vendor.accountNumber");

I thought I could do something like this:

super(new CompoundPropertyModel(new Vendor()));

The ListChoice is the same as above and the TextField like this:

TextField accountNumberField = new
TextField("accountNumber");

The problem with this is that the ListChoice is trying to set a property
on the model named vendor when I realy want the selected ListChoice
vendor object be the model object and have the TextField access the
accountNumber property of the ListChoice vendor.

How should I set up my model to deal with this type of situation or is a
ValueMap the best way?

Thanks,

Warren




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



Re: Model Question

2009-07-06 Thread Linda van der Pal
Is there a Calendar object under the covers somewhere? Cause it looks 
like a conversion error, seeing how the months start counting from zero 
in the Calendar object.


Regards,
Linda

jpalmer1...@mchsi.com wrote:
I have the following code to allow the user to select the date that a 
report is to be generated for. For some reason, though, whatever date 
is selected from the textfield, the previous date is being used. For 
example, if the user inputs 07/06/2009 into the dateTextField, 
07/05/2009 is being used. I'm assuming this is because I'm using the 
wrong model, so any assistance would be greatly appreciated.


public class AccountingDashboardPage extends EzdecBaseWebPage {
private Date date;

public AccountingDashboardPage(Date date) {
if (date == null) {
this.date = new Date();
}

Form form = new Form("accountingDashboardForm", new 
PropertyModel(this, "date")) {

@Override
protected void onSubmit() {
Date d = (Date)getModelObject();
setResponsePage(new AccountingDashboardPage(d));
}
};

add(form);

EzdecDateTextField reportDate = new 
EzdecDateTextField("stampDate", form.getModel());
reportDate.setModelValue(new String[]{new 
SimpleDateFormat("MM/dd/").format(date).toString()});

form.add(reportDate);

   

}

}




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.375 / Virus Database: 270.13.5/2220 - Release Date: 07/05/09 17:54:00


  



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



Model Question

2009-07-06 Thread jpalmer1026





I have the following code to allow the user to select the date that a report is to be generated for. For some reason, though, whatever date is selected from the textfield, the previous date is being used. For example, if the user inputs 07/06/2009 into the dateTextField, 07/05/2009 is being used. I'm assuming this is because I'm using the wrong model, so any assistance would be greatly appreciated.public class AccountingDashboardPage extends EzdecBaseWebPage {    private Date date;    public AccountingDashboardPage(Date date) {    if (date == null) {    this.date = new Date();    }    Form form = new Form("accountingDashboardForm", new PropertyModel(this, "date")) {    @Override    protected void onSubmit() {    Date d = (Date)getModelObject();    setResponsePage(new AccountingDashboardPage(d));    }    };    add(form);    EzdecDateTextField reportDate = new EzdecDateTextField("stampDate", form.getModel());    reportDate.setModelValue(new String[]{new SimpleDateFormat("MM/dd/").format(date).toString()});    form.add(reportDate);        }}






Re: simple model question

2009-05-29 Thread bferr

I was not chaining the models as suggested and the ldm.getModelObject() does
not get updated sometimes.  Is that the type of problem that would be caused
by not chaining the models?  If so, it's only in some cases not all the
time.  My debugging brought me to review the models because it seemed like
sometimes they become different objects in memory.



igor.vaynberg wrote:
> 
> if you chain your models properly its no problem..
> 
> imodel ldm=new loadabledetachablemodel(..)
> imodel prop=new propertymodel(ldm, "prop");
> 
> -igor
> 
> On Wed, May 27, 2009 at 1:20 PM, bf  wrote:
>> I constructed a Page that uses a LoadableDetachableModel.  The
>> LoadableDetachableModel retrieves an object from the Session and displays
>> Panels from a list in the object.  The Panels have TextFields which use
>> elements from the List but it puts the object into a PropertyModel in
>> order to access the attributes.
>> My question is whether it is a problem to update the TextField via the
>> PropertyModel or does the PropertyModel have to use a
>> LoadableDetachableModel as well in order to get the object from the
>> Session before doing an update?
> 

-- 
View this message in context: 
http://www.nabble.com/simple-model-question-tp23750088p23786425.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: simple model question

2009-05-27 Thread Igor Vaynberg
if you chain your models properly its no problem..

imodel ldm=new loadabledetachablemodel(..)
imodel prop=new propertymodel(ldm, "prop");

-igor

On Wed, May 27, 2009 at 1:20 PM, bf  wrote:
> I constructed a Page that uses a LoadableDetachableModel.  The 
> LoadableDetachableModel retrieves an object from the Session and displays 
> Panels from a list in the object.  The Panels have TextFields which use 
> elements from the List but it puts the object into a PropertyModel in order 
> to access the attributes.
> My question is whether it is a problem to update the TextField via the 
> PropertyModel or does the PropertyModel have to use a LoadableDetachableModel 
> as well in order to get the object from the Session before doing an update?
> Thanks
> 
>  Study criminal justice and earn your degree. Click here to request free 
> program info!
> http://thirdpartyoffers.juno.com/TGL2131/fc/BLSrjnsC7KBxeazkJEKLTcG5VrnBxiF6Isv6JgQMUhUTSRgwIiVlASqMnxG/

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



simple model question

2009-05-27 Thread bf
I constructed a Page that uses a LoadableDetachableModel.  The 
LoadableDetachableModel retrieves an object from the Session and displays 
Panels from a list in the object.  The Panels have TextFields which use 
elements from the List but it puts the object into a PropertyModel in order to 
access the attributes.  
My question is whether it is a problem to update the TextField via the 
PropertyModel or does the PropertyModel have to use a LoadableDetachableModel 
as well in order to get the object from the Session before doing an update?
Thanks

 Study criminal justice and earn your degree. Click here to request free 
program info!
http://thirdpartyoffers.juno.com/TGL2131/fc/BLSrjnsC7KBxeazkJEKLTcG5VrnBxiF6Isv6JgQMUhUTSRgwIiVlASqMnxG/

Component Model question

2009-04-13 Thread Craig Tataryn
I have a component I'm designing where it displays a list of items to  
the user, so the setup for the component on the page might look like  
this:


add(new MultiTextInput>("tags", new  
ArrayList() {

{
add("apple");
add("banana");
}
}));

The widget will render two sets of hidden inputs, one for the original/ 
additional items (name="tags") which were entered and one for deleted  
items (name="removed_tags").


For instance:






The above would result from me keeping apple and adding peach, grape,  
and removing banana.


I'm a bit stuck on how I should get my component to put these values  
back into it's model?  Obviously in behind the scenes I'm going to  
have to do some stuff in the MultiTextInput ctor to have the incoming  
Collection added to a composite model that contains both the original/ 
added items and the removed items.


I'm just not sure where I broker the form submittal so that I have a  
chance to move the "tags" and "removed_tags" into the proper place in  
the model for my component.  When the user calls getModelObject() on  
my component they'll get an object back where they can query  
model.getItems() and model.getRemovedItems().


As always, any help greatly appreciated!

Craig.

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



Re: Component Model question

2009-04-10 Thread Igor Vaynberg
no, all you have to do is override convertinput and inside call
setconvertedinput(yourcollection);

the default implementation of updatemodel() already does
getmodel().setobject(getconvertedinput());

-igor

On Fri, Apr 10, 2009 at 3:29 PM, Craig Tataryn  wrote:
> On 10-Apr-09, at 3:10 PM, Igor Vaynberg wrote:
>
>> look at textfield.
>>
>> all you have to do is to write out the input tags with a name you
>> obtain from formcomponent.getname() - to guarantee uniqueness, then
>> override convertinput() and pull those values out of the request into
>> a collection and call setconvertedinput(collection). formcomponent
>> will take care of everything else such as validation and updating the
>> model. thats all there is to it.
>>
>
> Thanks Igor, in my version I had overridden updateModel like so to get it
> working:
>
>        public void updateModel() {
>                String[] added = this.getInputAsArray();
>                String[] removed = getRequest().getParameters("removed_" +
> getInputName());
>                MultiTextInputModel model = (MultiTextInputModel)
> this.getModel();
>                model.setItems(added == null ? EMPTY_STRING_COL :
> Arrays.asList(added));
>                model.setRemovedItems(removed == null ? EMPTY_STRING_COL :
> Arrays.asList(removed));
>
>        }
> I'm assuming that convertInput fires before update model, so I should
> override that method as you suggest to handle different types but maintain
> my updateModel as well to shovel things into the right places in the model?
>
> Craig.
>
>> -igor
>>
>> On Fri, Apr 10, 2009 at 10:49 AM, Craig Tataryn 
>> wrote:
>>>
>>> I have a component I'm designing where it displays a list of items to the
>>> user, so the setup for the component on the page might look like this:
>>>
>>>      add(new MultiTextInput>("tags", new
>>> ArrayList() {
>>>       {
>>>               add("apple");
>>>               add("banana");
>>>       }
>>>      }));
>>>
>>> The widget will render two sets of hidden inputs, one for the
>>> original/additional items (name="tags") which were entered and one for
>>> deleted items (name="removed_tags").
>>>
>>> For instance:
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>>> The above would result from me keeping apple and adding peach, grape, and
>>> removing banana.
>>>
>>> I'm a bit stuck on how I should get my component to put these values back
>>> into it's model?  Obviously in behind the scenes I'm going to have to do
>>> some stuff in the MultiTextInput ctor to have the incoming Collection
>>> added
>>> to a composite model that contains both the original/added items and the
>>> removed items.
>>>
>>> I'm just not sure where I broker the form submittal so that I have a
>>> chance
>>> to move the "tags" and "removed_tags" into the proper place in the model
>>> for
>>> my component.  When the user calls getModelObject() on my component
>>> they'll
>>> get an object back where they can query model.getItems() and
>>> model.getRemovedItems().
>>>
>>> As always, any help greatly appreciated!
>>>
>>> Craig.
>>>
>>> --
>>> Craig Tataryn
>>> site: http://www.basementcoders.com/
>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>> twitter: craiger
>>
>> -
>> 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
>
>

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



Re: Component Model question

2009-04-10 Thread Craig Tataryn

On 10-Apr-09, at 3:10 PM, Igor Vaynberg wrote:


look at textfield.

all you have to do is to write out the input tags with a name you
obtain from formcomponent.getname() - to guarantee uniqueness, then
override convertinput() and pull those values out of the request into
a collection and call setconvertedinput(collection). formcomponent
will take care of everything else such as validation and updating the
model. thats all there is to it.



Thanks Igor, in my version I had overridden updateModel like so to get  
it working:


public void updateModel() {
String[] added = this.getInputAsArray();
		String[] removed = getRequest().getParameters("removed_" +  
getInputName());

MultiTextInputModel model = (MultiTextInputModel) 
this.getModel();
		model.setItems(added == null ? EMPTY_STRING_COL :  
Arrays.asList(added));
		model.setRemovedItems(removed == null ? EMPTY_STRING_COL :  
Arrays.asList(removed));


}
I'm assuming that convertInput fires before update model, so I should  
override that method as you suggest to handle different types but  
maintain my updateModel as well to shovel things into the right places  
in the model?


Craig.


-igor

On Fri, Apr 10, 2009 at 10:49 AM, Craig Tataryn  
 wrote:
I have a component I'm designing where it displays a list of items  
to the
user, so the setup for the component on the page might look like  
this:


  add(new MultiTextInput>("tags", new
ArrayList() {
   {
   add("apple");
   add("banana");
   }
  }));

The widget will render two sets of hidden inputs, one for the
original/additional items (name="tags") which were entered and one  
for

deleted items (name="removed_tags").

For instance:






The above would result from me keeping apple and adding peach,  
grape, and

removing banana.

I'm a bit stuck on how I should get my component to put these  
values back
into it's model?  Obviously in behind the scenes I'm going to have  
to do
some stuff in the MultiTextInput ctor to have the incoming  
Collection added
to a composite model that contains both the original/added items  
and the

removed items.

I'm just not sure where I broker the form submittal so that I have  
a chance
to move the "tags" and "removed_tags" into the proper place in the  
model for
my component.  When the user calls getModelObject() on my component  
they'll

get an object back where they can query model.getItems() and
model.getRemovedItems().

As always, any help greatly appreciated!

Craig.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger


-
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



Re: Component Model question

2009-04-10 Thread Igor Vaynberg
look at textfield.

all you have to do is to write out the input tags with a name you
obtain from formcomponent.getname() - to guarantee uniqueness, then
override convertinput() and pull those values out of the request into
a collection and call setconvertedinput(collection). formcomponent
will take care of everything else such as validation and updating the
model. thats all there is to it.

-igor

On Fri, Apr 10, 2009 at 10:49 AM, Craig Tataryn  wrote:
> I have a component I'm designing where it displays a list of items to the
> user, so the setup for the component on the page might look like this:
>
>       add(new MultiTextInput>("tags", new
> ArrayList() {
>        {
>                add("apple");
>                add("banana");
>        }
>       }));
>
> The widget will render two sets of hidden inputs, one for the
> original/additional items (name="tags") which were entered and one for
> deleted items (name="removed_tags").
>
> For instance:
>
> 
> 
> 
> 
>
> The above would result from me keeping apple and adding peach, grape, and
> removing banana.
>
> I'm a bit stuck on how I should get my component to put these values back
> into it's model?  Obviously in behind the scenes I'm going to have to do
> some stuff in the MultiTextInput ctor to have the incoming Collection added
> to a composite model that contains both the original/added items and the
> removed items.
>
> I'm just not sure where I broker the form submittal so that I have a chance
> to move the "tags" and "removed_tags" into the proper place in the model for
> my component.  When the user calls getModelObject() on my component they'll
> get an object back where they can query model.getItems() and
> model.getRemovedItems().
>
> As always, any help greatly appreciated!
>
> Craig.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> twitter: craiger

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



Re: Component Model question

2009-04-10 Thread Martin Makundi
> So if it's possible for me to (easily) map those two sets of hidden inputs
> to my model upon form submit I'd really like to know how.

What specifically is the difficult part?

**
Martin

>

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



Re: Component Model question

2009-04-10 Thread Craig Tataryn

On 10-Apr-09, at 12:58 PM, Martin Makundi wrote:


Are you trying to handle state on client side? While that is possible,
it is not the purpose of Wicket. Would you consider managing he state
on server side?



It's an existing javascript widget I wrote so I was looking for a  
quick port to Wicket. However there is no reason there couldn't be two  
versions, the Ajax version could redraw everything serverside upon  
addition/deletion of items.


So if it's possible for me to (easily) map those two sets of hidden  
inputs to my model upon form submit I'd really like to know how.


Thanks,

Craig.


**
Martin

2009/4/10 Craig Tataryn :
I have a component I'm designing where it displays a list of items  
to the
user, so the setup for the component on the page might look like  
this:


 add(new MultiTextInput>("tags", new
ArrayList() {
  {
  add("apple");
  add("banana");
  }
 }));

The widget will render two sets of hidden inputs, one for the
original/additional items (name="tags") which were entered and one  
for

deleted items (name="removed_tags").

For instance:






The above would result from me keeping apple and adding peach,  
grape, and

removing banana.

I'm a bit stuck on how I should get my component to put these  
values back
into it's model?  Obviously in behind the scenes I'm going to have  
to do
some stuff in the MultiTextInput ctor to have the incoming  
Collection added
to a composite model that contains both the original/added items  
and the

removed items.

I'm just not sure where I broker the form submittal so that I have  
a chance
to move the "tags" and "removed_tags" into the proper place in the  
model for
my component.  When the user calls getModelObject() on my component  
they'll

get an object back where they can query model.getItems() and
model.getRemovedItems().

As always, any help greatly appreciated!

Craig.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger


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





Re: Component Model question

2009-04-10 Thread Martin Makundi
Are you trying to handle state on client side? While that is possible,
it is not the purpose of Wicket. Would you consider managing he state
on server side?

**
Martin

2009/4/10 Craig Tataryn :
> I have a component I'm designing where it displays a list of items to the
> user, so the setup for the component on the page might look like this:
>
>   add(new MultiTextInput>("tags", new
> ArrayList() {
>{
>add("apple");
>add("banana");
>}
>   }));
>
> The widget will render two sets of hidden inputs, one for the
> original/additional items (name="tags") which were entered and one for
> deleted items (name="removed_tags").
>
> For instance:
>
> 
> 
> 
> 
>
> The above would result from me keeping apple and adding peach, grape, and
> removing banana.
>
> I'm a bit stuck on how I should get my component to put these values back
> into it's model?  Obviously in behind the scenes I'm going to have to do
> some stuff in the MultiTextInput ctor to have the incoming Collection added
> to a composite model that contains both the original/added items and the
> removed items.
>
> I'm just not sure where I broker the form submittal so that I have a chance
> to move the "tags" and "removed_tags" into the proper place in the model for
> my component.  When the user calls getModelObject() on my component they'll
> get an object back where they can query model.getItems() and
> model.getRemovedItems().
>
> As always, any help greatly appreciated!
>
> Craig.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> twitter: craiger

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



Component Model question

2009-04-10 Thread Craig Tataryn
I have a component I'm designing where it displays a list of items to  
the user, so the setup for the component on the page might look like  
this:


   add(new MultiTextInput>("tags", new  
ArrayList() {

{
add("apple");
add("banana");
}
   }));

The widget will render two sets of hidden inputs, one for the original/ 
additional items (name="tags") which were entered and one for deleted  
items (name="removed_tags").


For instance:






The above would result from me keeping apple and adding peach, grape,  
and removing banana.


I'm a bit stuck on how I should get my component to put these values  
back into it's model?  Obviously in behind the scenes I'm going to  
have to do some stuff in the MultiTextInput ctor to have the incoming  
Collection added to a composite model that contains both the original/ 
added items and the removed items.


I'm just not sure where I broker the form submittal so that I have a  
chance to move the "tags" and "removed_tags" into the proper place in  
the model for my component.  When the user calls getModelObject() on  
my component they'll get an object back where they can query  
model.getItems() and model.getRemovedItems().


As always, any help greatly appreciated!

Craig.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger

Re: Model question

2007-09-11 Thread Martijn Dashorst
Nothing directly. The only thing you should do is propagate the
'detach' method to your nested eventModel. The chaining model is
merely interesting for consumers of your model, so they can get to the
embedded model using a specified API.

>From chapter 5 "Understanding Models" of Wicket in Action (the custom
models part where the quote comes from may become an appendix though):

"To summarize, when you want to chain models, be sure to propagate the
detach call to the chained models. This way the whole chain will be
detached. If your custom model is part of a public API, your clients
will most likely thank you when you implement the IChainingModel
interface, providing them access to the inner model."

The IWrapModel is used for marking models that have been wrapped using
IComponentAssignedModel or IComponentInheritedModel.

Martijn

On 9/11/07, Leszek Gawron <[EMAIL PROTECTED]> wrote:
> Assuming eventModel is loadable detachable model sould I implement some
> marker interfaces in the following model?
>
> > private static class SystemWarningEventImagePathModel extends 
> > AbstractReadOnlyModel {
> >   private IModel  eventModel;
> >
> >   public SystemWarningEventImagePathModel( IModel eventModel ) {
> >   this.eventModel = eventModel;
> >   }
> >
> >   @Override
> >   public Object getObject() {
> >   SystemWarningEvent event = (SystemWarningEvent) 
> > eventModel.getObject();
> >   return event.isReadFlag() ? "img/mobile/event_read.png" : 
> > "img/mobile/event_new.png";
> >   }
> > }
>
>
> There are a number to take into account: IWrapModel, IChainingModel.
> Please advise.
>
> --
> Leszek Gawron
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Model question

2007-09-11 Thread Leszek Gawron
Assuming eventModel is loadable detachable model sould I implement some 
marker interfaces in the following model?



private static class SystemWarningEventImagePathModel extends 
AbstractReadOnlyModel {
private IModel  eventModel;

public SystemWarningEventImagePathModel( IModel eventModel ) {
this.eventModel = eventModel;
}

@Override
public Object getObject() {
SystemWarningEvent event = (SystemWarningEvent) 
eventModel.getObject();
return event.isReadFlag() ? "img/mobile/event_read.png" : 
"img/mobile/event_new.png";
}
}



There are a number to take into account: IWrapModel, IChainingModel. 
Please advise.


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]