Re: CompoundPropertyModel - white space

2021-06-08 Thread Mihir Chhaya
Thank you, Sven. This is working.

As always, The Apache Wicket team ROCKS !!

-Mihir.

On Tue, Jun 8, 2021 at 3:54 PM Sven Meier  wrote:

> Hi,
>
> by default textfields trim their input, so I'd expect the total count
> characters to be correct to the processed input:
>
>"f " + "m" + "l" -> "fml" = 3 characters (also a space was entered
> after the *f*
>
> You might want to override #shouldTrimInput if you want to keep the
> whitespace.
>
> Have fun
> Sven
>
>
> On 08.06.21 21:05, Mihir Chhaya wrote:
> > Hello,
> >
> > Apache Wicket version used: 8.12.0
> >
> > I need to show total characters entered into First, Middle and Last name
> > text fields + one drop down for Suffix. The combined length of these four
> > fields should not exceed the set limit.
> > For this, I have added OnChangeAjaxBehavior to all the three text fields
> +
> > the drop down.
> >
> > These fields are bound to the respective bean properties using
> > CompoundProperyModel. The bean has a generic getter method to calculate
> > combined length without trimming white space from any field.
> >
> > Issue:
> > The CompoundPropertyModel bean setter method is not called when a white
> > space is entered after any letter in the field.
> > For example, entering "f" in the first name will call the setter method,
> > but entering white space after "f" does not call the setter method until
> > the next character is entered.
> > This is messing up the total chars count.
> >
> > Here is how the length looks like without any white space trimming:
> >
> > (1) F + M + L = "f" + "m" + "l" = 3
> > (2) F + M + L = "f " + "m" + "l" = 3 (Please note the white space after
> f)
> > (3) F + M + L = "f n" + "m" + "l" = 5
> >
> > As one can see, the 2nd scenario is what I am trying to solve.
> >
> > The OnChangeAjaxBehavior event is called when entering the white space,
> but
> > the bean setter is not, causing misleading total chars count.
> >
> > Any suggestions?
> >
> > Thank you,
> > -Mihir.
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: CompoundPropertyModel - white space

2021-06-08 Thread Sven Meier

Hi,

by default textfields trim their input, so I'd expect the total count 
characters to be correct to the processed input:


  "f " + "m" + "l" -> "fml" = 3 characters (also a space was entered 
after the *f*


You might want to override #shouldTrimInput if you want to keep the 
whitespace.


Have fun
Sven


On 08.06.21 21:05, Mihir Chhaya wrote:

Hello,

Apache Wicket version used: 8.12.0

I need to show total characters entered into First, Middle and Last name
text fields + one drop down for Suffix. The combined length of these four
fields should not exceed the set limit.
For this, I have added OnChangeAjaxBehavior to all the three text fields +
the drop down.

These fields are bound to the respective bean properties using
CompoundProperyModel. The bean has a generic getter method to calculate
combined length without trimming white space from any field.

Issue:
The CompoundPropertyModel bean setter method is not called when a white
space is entered after any letter in the field.
For example, entering "f" in the first name will call the setter method,
but entering white space after "f" does not call the setter method until
the next character is entered.
This is messing up the total chars count.

Here is how the length looks like without any white space trimming:

(1) F + M + L = "f" + "m" + "l" = 3
(2) F + M + L = "f " + "m" + "l" = 3 (Please note the white space after f)
(3) F + M + L = "f n" + "m" + "l" = 5

As one can see, the 2nd scenario is what I am trying to solve.

The OnChangeAjaxBehavior event is called when entering the white space, but
the bean setter is not, causing misleading total chars count.

Any suggestions?

Thank you,
-Mihir.



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



Re: CompoundPropertyModel: override method or catch exception

2015-06-17 Thread Martin Grigorov
Hi,

Then you need to roll your own IModel and use it instead of
CompountPropertyModel.
**PropertyModel classes use reflection to find and call the setter and
getter methods.

Martin Grigorov
Freelancer. Available for hire!
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jun 16, 2015 at 9:23 PM, sorinev  wrote:

> To go with my  other thread
> <
> http://apache-wicket.1842946.n4.nabble.com/TextField-AjaxEventBehavior-onBlur-onEvent-tp4671150.html
> >
> about the same form page, I have an issue with the CompoundPropertyModel.
> There is a TextField in a form on this page, and the corresponding setter
> in
> the model can throw an exception. When it does, wicket crashes the page. It
> seems that it's using reflection by grabbing the name of the component on
> the page, and looking for a setter for that component in the model
> automatically behind the scenes.
>
> What I need to have happen is either I can somehow override that method
> through the CompoundPropertyModel, or just catch exceptions from the model
> in general, or maybe some other mechanism. In any case, what I need is to
> be
> able to cleanly reset things on the page in the case of an exception rather
> than the page crashing altogether.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-override-method-or-catch-exception-tp4671205.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: CompoundPropertyModel binding direction

2013-03-19 Thread Sven Meier

However I'm curious to know if a possible solution would be to create the
DetailPage instance inside the onClick method of the Link, so that it becomes
a local variable that gets collected asap.


Sure, that's perfectly fine.

Sven


On 03/19/2013 11:39 AM, Lucio Crusca wrote:

In data Tuesday 19 March 2013 09:42:54, Sven Meier ha scritto:

Hi Lucio,
FormComponentPanels are an advanced concept and I'd recommend you extend
org.apache.wicket.markup.html.panel.Panel until you really need the
features of a FormComponentPanel.

Thanks that solved the problem.


BTW your HomePage shouldn't keep a reference to another page (i.e.
DetailPage), since Wicket serialized pages separately.

Well, to be honest I don't understand the full meaning of the sentence (why my
design conflicts with Wicket serialization), but let's leave that to Google,
I'll have a look.

However I'm curious to know if a possible solution would be to create the
DetailPage instance inside the onClick method of the Link, so that it becomes
a local variable that gets collected asap.



-
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: CompoundPropertyModel binding direction

2013-03-19 Thread Lucio Crusca
In data Tuesday 19 March 2013 09:42:54, Sven Meier ha scritto:
> Hi Lucio,

> FormComponentPanels are an advanced concept and I'd recommend you extend
> org.apache.wicket.markup.html.panel.Panel until you really need the
> features of a FormComponentPanel.

Thanks that solved the problem.

> BTW your HomePage shouldn't keep a reference to another page (i.e.
> DetailPage), since Wicket serialized pages separately.

Well, to be honest I don't understand the full meaning of the sentence (why my 
design conflicts with Wicket serialization), but let's leave that to Google, 
I'll have a look.

However I'm curious to know if a possible solution would be to create the 
DetailPage instance inside the onClick method of the Link, so that it becomes 
a local variable that gets collected asap.



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



Re: CompoundPropertyModel binding direction

2013-03-19 Thread Sven Meier

Hi Lucio,

your LabelAndField and DetailFormComponentPanel both extend 
FormComponentPanel. Thus they will take part in form processing and try 
to push a value into their model.
Since there are no properties "singlePanelForCurrentRow" and 
"detailEditorPanel" the model update will fail.


FormComponentPanels are an advanced concept and I'd recommend you extend 
org.apache.wicket.markup.html.panel.Panel until you really need the 
features of a FormComponentPanel.


BTW your HomePage shouldn't keep a reference to another page (i.e. 
DetailPage), since Wicket serialized pages separately.


Hope this helps
Sven

On 03/18/2013 10:23 PM, Lucio Crusca wrote:

I'm trying to use CompoundPropertyModel in a form I dynamically create with a
RepeatingView. I use the CompoundPropertyModel#bind method to bind each input
tag to the corresponding java bean property.

Binding from java bean to html does work (the fields get filled), while the
other way around (onSubmit) does break... the reported error is "no get method
defined ... singlePanelForCurrentRow", where singlePanelForCurrentRow is the
wicket:id I use to attach the repeating input tags.

I don't know what to search for on Google, because searching obvious terms
(CompoundPropertyModel binding and the like) yelds trivial examples, but
nothing similar to my needs.

Here is a quickstart demonstrating the issue, try clicking submit:

http://www.virtualbit.it/download/sparsi/example.zip

Thanks in advance
Lucio.

-
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: CompoundPropertyModel not working... Warning message

2012-10-13 Thread delta458
Ah great. It works now.

I enabled the validation and somehow it works now... I tested it x times
before with no results..

well thanks.. :)



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-not-working-Warning-message-tp4652942p4652946.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: CompoundPropertyModel not working... Warning message

2012-10-13 Thread Dan Retzlaff
If you don't add any of the standard validators, doesn't that accomplish
your goal? I think you still want "form processing" which includes
population of model objects from the raw submitted strings.

If you're using another post-submit validation framework, you probably want
to override Form#onValidateModelObjects() which is for that purpose.

On Sun, Oct 14, 2012 at 1:19 AM, delta458  wrote:

> I disabled default form processing because I need to, for my project. I
> will
> use another validation framework for validating.
>
> Also when it is enabled, my object was not populated...
>
> I will try again though...
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-not-working-Warning-message-tp4652942p4652944.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: CompoundPropertyModel not working... Warning message

2012-10-13 Thread delta458
I disabled default form processing because I need to, for my project. I will
use another validation framework for validating. 

Also when it is enabled, my object was not populated...

I will try again though...



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-not-working-Warning-message-tp4652942p4652944.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: CompoundPropertyModel not working... Warning message

2012-10-13 Thread Dan Retzlaff
Hi!

It's not clear what you mean by "not working" but I'll assume you expect
your Invoice object to be populated when the submit button is clicked. It
won't work with your code because you have disabled default form processing
with your submit button. You actually don't even need a Wicket component
for the submit button. Just include an  inside your
form markup. To handle the submit, you can override Form#onSubmit().

The warning message is not related to your form model issues. Maybe you're
referring to wicket-logo.png with a PackageResourceReference but it's not
actually alongside BasePage?

Hope that helps,
Dan

On Sun, Oct 14, 2012 at 12:12 AM, delta458  wrote:

> Tried so much... still not working..
> I get the following warning message:
> /WARNING: A ResourceReference wont be created for a resource with key
> [scope: template.BasePage; name: wicket-logo.png; locale: null; style:
> null;
> variation: null] because it cannot be located./
>
> Here is the Java File:
>
>
> And the HTML file:
>
>
>
>
> What am I missing?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-not-working-Warning-message-tp4652942.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: CompoundPropertyModel problem.. the values are not refreshing

2012-06-14 Thread ramlael
Wicket 1.5

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-problem-the-values-are-not-refreshing-tp4649987p464.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: CompoundPropertyModel problem.. the values are not refreshing

2012-06-14 Thread Sven Meier

What Wicket version?

BTW a quickstart would enable us to help you.

Sven

On 06/14/2012 05:45 PM, ramlael wrote:

Below are my files

HTML

  

Bean
Customer.java  - getters/setters for firstName and lastname

Component.java  - On URL getting the firstname and lastNames as page
parameters
Customer customer = new Customer();
CompoundPropertyModel  compoundPropertyModel = new
CompoundPropertyModel(customer );
 final Form  addCardForm= new
Form("addCardForm",compoundPropertyModel);

customer.setFirstName(parameters.get("firstName").toString());
customer.setLastName(parameters.get("lastName").toString());

final TextField firstName = new TextField("firstName");
 final TextField lastName = new TextField("lastName");
addCardForm.add(firstName );
addCardForm.add(lastName);
add(addCardForm);


Here the Problems:

1) Once I load the file with URL :
localhost:8080/addcard?firstName=ram&lastName=babu, the first name and last
name displaying fine but if I change the firstName and lastName in same
browser URL like localhost:8080/addcard?firstName=ravi&lastName=suri, the
old values(ram,babu) only displaying in form fields(First Name and Last
Name)

2) The form has AjaxSubmitLink- once I load the page with ram and babu,
changed the first name ram to raj, and clicked submit button. if the page
has any error the error message is writing to feed back panel but the First
name is changing to old value that is ram.

Is It problem with CompoundPropertyModel or cache probelm.. please suggest
me the solution.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-problem-the-values-are-not-refreshing-tp4649987.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



Re: CompoundPropertyModel problem.. the values are not refreshing

2012-06-14 Thread ramlael
1) In form have 2 text fields, 1) First Name and 2) Last Name. On page load
populating the values with request parameters like
https:localhost:8080/addcard?firstName=ram&lastName=babu.  after loading the
page with first name and last name field, modified the first name text field
with "raj" , clicked submit button. got the error on page ( have some
mandatory fields in the page) and displayed the error on feed back panel but
the first name text field changed to old value (ram). it should be raj... 


2) after loading the page withurl
https:localhost:8080/addcard?firstName=ram&lastName=babu . I have changed
the URL like https:localhost:8080/addcard?firstName=ravi&lastName=babu in
same browser and clicked enter but the first name text field value
populating with old value ram not with ravi.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertyModel-problem-the-values-are-not-refreshing-tp4649987p4649993.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: CompoundPropertyModel problem.. the values are not refreshing

2012-06-14 Thread Thomas Götz
Could you please provide a Quickstart that describes your problem? This will 
make it much easier for us to help you.

   -Tom


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



RE: CompoundPropertyModel and FormComponent

2012-01-18 Thread Schlärmann , Bob
Thanks for your response. After some more debugging I've found the cause and 
also found a solution.

The cause is that models of intermediate components, such as the Panel in my 
case, are never initialized if they do not already have a model. 

The parent's model is looked up in Component.initModel(), however this method 
uses a special method for getting the model of the parent that does not 
initialize the parent's model if it is not already initialized. The behaviour 
is intentional as there is a comment on this line:

// Get model
// Don't call the getModel() that could initialize many inbetween
// completely useless models.
// IModel model = current.getModel();
IModel model = current.getModelImpl();

In my case I think this intermediate the inbetween model should get 
initialized. 

The workaround is to initialize the model in onBeforeRender(), before calling 
super.onBeforeRender(), and let the Panel implement the IFormVisitorParticipant 
interface. Then in IFormVisitorParticipant.processChildren() initialize the 
model again (by just calling getDefaultModel()). This last trick is needed in 
order to get the model initialized before it's children are submitted.

The complete class is as follows:

public class AddressPanel extends Panel implements IFormVisitorParticipant {
public AddressPanel(String id) {
super(id);

add(new TextField("street"));
}

protected IModel initModel() {
IModel model = super.initModel();

return new CompoundPropertyModel(model);
}

protected void onBeforeRender() {
getDefaultModel(); // getDefaultModel initialized model if not yet 
initialized

   super.onBeforeRender();
}

public boolean processChildren() {
getDefaultModel();

return true;
}
}

In SomePage.class you can "bind" the panel to an Address property:

Address address; // consists of a single property named street

SomePage() {
   Form form = new Form("form", new 
CompoundPropertyModel(this));
   form.add(new AddressPanel("address"));
   add(form);
}


This solution seems a bit awkward though so I'm using a constructor with model 
solution in my application.

Best regards,

Bob


> At this point I would override/debug method updateModel() inside
> AddressPanel to see if model's object is modified by this method .
> Just my 2 cents...
> >> Yes, I think you are doing it "the Wicket way", but your snippet and
> >> mine should work. Do you modify components' model somewhere else?
> > No, I don't think so. The page to which the component is added is
> constructed as follows:
> >
> > CompoundPropertyModel  model = new
> CompoundPropertyModel(this);
> > Form  form = new Form("form", model);
> > form.add(new TextField("person.firstname"));
> > form.add(new AdresPanel("person.adres"));
> >
> > No other code modifies the model.
> >
> >>> Which model do you get if you call getDefaultModel() inside oninitialize?
> > The result of getDefaultModel() is an instance of
> CompoundPropertyModel$AttachedCompoundPropertyModel, with owner set to the
> AdresPanel and with target set to a CompoundPropertyModel which in turn has
> target HomePage.
> >
> > I noticed that upon initializing the model is set correctly. However when
> inspecting the model in onBeforeRender() during the submit request the target
> of the model of the AddressPanel.street model is set to HomePage.
> >
> >>> Thanks for your reply. I've tried it but it still gave the same error.
> >>>
> >>> However I also tried the following modified version of your idea:
> >>>
> >>> In AddressPanel.java:
> >>>
> >>> @Override
> >>> protected void onInitialize() {
> >>>   super.onInitialize();
> >>>  Object o = getDefaultModelObject();
> >>>
> >>>  setDefaultModel(new
> CompoundPropertyModel(getDefaultModelObject()));
> >>> }
> >>>
> >>> With the above code I can now load the page, also the
> >> getDefaultModelObject() returns the correct Address instance. Unfortunately
> >> upon submitting the form I get the same exception again ("No get method
> >> defined for class: class foo.HomePage expression: street").
> >>> By the way: am I doing things "the Wicket way"? Is this how you would
> reuse
> >> parts of a form in Wicket?
> >>>
> >>>
> >>> Best regards,
> >>>
> >>> Bob
> >>>
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >
> > Think green - keep it on the screen.
> >
> > This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an intended
> recipient then please promptly delete this e-mail and any attachment and all
> copies and inform the s

Re: CompoundPropertyModel and FormComponent

2012-01-18 Thread Andrea Del Bene
At this point I would override/debug method updateModel() inside 
AddressPanel to see if model's object is modified by this method .

Just my 2 cents...

Yes, I think you are doing it "the Wicket way", but your snippet and
mine should work. Do you modify components' model somewhere else?

No, I don't think so. The page to which the component is added is constructed 
as follows:

CompoundPropertyModel  model = new 
CompoundPropertyModel(this);
Form  form = new Form("form", model);
form.add(new TextField("person.firstname"));
form.add(new AdresPanel("person.adres"));

No other code modifies the model.


Which model do you get if you call getDefaultModel() inside oninitialize?

The result of getDefaultModel() is an instance of 
CompoundPropertyModel$AttachedCompoundPropertyModel, with owner set to the 
AdresPanel and with target set to a CompoundPropertyModel which in turn has 
target HomePage.

I noticed that upon initializing the model is set correctly. However when 
inspecting the model in onBeforeRender() during the submit request the target 
of the model of the AddressPanel.street model is set to HomePage.


Thanks for your reply. I've tried it but it still gave the same error.

However I also tried the following modified version of your idea:

In AddressPanel.java:

@Override
protected void onInitialize() {
super.onInitialize();
 Object o = getDefaultModelObject();

 setDefaultModel(new CompoundPropertyModel(getDefaultModelObject()));
}

With the above code I can now load the page, also the

getDefaultModelObject() returns the correct Address instance. Unfortunately
upon submitting the form I get the same exception again ("No get method
defined for class: class foo.HomePage expression: street").

By the way: am I doing things "the Wicket way"? Is this how you would reuse

parts of a form in Wicket?



Best regards,

Bob



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



Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.



-
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: CompoundPropertyModel and FormComponent

2012-01-16 Thread Schlärmann , Bob
> Yes, I think you are doing it "the Wicket way", but your snippet and
> mine should work. Do you modify components' model somewhere else? 
No, I don't think so. The page to which the component is added is constructed 
as follows:

CompoundPropertyModel model = new 
CompoundPropertyModel(this);
Form form = new Form("form", model);
form.add(new TextField("person.firstname"));
form.add(new AdresPanel("person.adres"));

No other code modifies the model.

> > Which model do you get if you call getDefaultModel() inside oninitialize?
The result of getDefaultModel() is an instance of 
CompoundPropertyModel$AttachedCompoundPropertyModel, with owner set to the 
AdresPanel and with target set to a CompoundPropertyModel which in turn has 
target HomePage.

I noticed that upon initializing the model is set correctly. However when 
inspecting the model in onBeforeRender() during the submit request the target 
of the model of the AddressPanel.street model is set to HomePage.

> > Thanks for your reply. I've tried it but it still gave the same error.
> >
> > However I also tried the following modified version of your idea:
> >
> > In AddressPanel.java:
> >
> > @Override
> > protected void onInitialize() {
> > super.onInitialize();
> > Object o = getDefaultModelObject();
> >
> > setDefaultModel(new CompoundPropertyModel(getDefaultModelObject()));
> > }
> >
> > With the above code I can now load the page, also the
> getDefaultModelObject() returns the correct Address instance. Unfortunately
> upon submitting the form I get the same exception again ("No get method
> defined for class: class foo.HomePage expression: street").
> >
> > By the way: am I doing things "the Wicket way"? Is this how you would reuse
> parts of a form in Wicket?
> >
> >
> >
> > Best regards,
> >
> > Bob
> >
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 


Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.



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



Re: CompoundPropertyModel and FormComponent

2012-01-16 Thread Andrea Del Bene
Yes, I think you are doing it "the Wicket way", but your snippet and 
mine should work. Do you modify components' model somewhere else? Which 
model do you get if you call getDefaultModel() inside oninitialize?

Thanks for your reply. I've tried it but it still gave the same error.

However I also tried the following modified version of your idea:

In AddressPanel.java:

@Override
protected void onInitialize() {
super.onInitialize();
Object o = getDefaultModelObject();

setDefaultModel(new CompoundPropertyModel(getDefaultModelObject()));
}

With the above code I can now load the page, also the getDefaultModelObject() returns the 
correct Address instance. Unfortunately upon submitting the form I get the same exception 
again ("No get method defined for class: class foo.HomePage expression: 
street").

By the way: am I doing things "the Wicket way"? Is this how you would reuse 
parts of a form in Wicket?



Best regards,

Bob




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



RE: CompoundPropertyModel and FormComponent

2012-01-16 Thread Schlärmann , Bob
Thanks for your reply. I've tried it but it still gave the same error. 

However I also tried the following modified version of your idea:

In AddressPanel.java:

@Override
protected void onInitialize() {
super.onInitialize();
   Object o = getDefaultModelObject();

   setDefaultModel(new CompoundPropertyModel(getDefaultModelObject()));
}

With the above code I can now load the page, also the getDefaultModelObject() 
returns the correct Address instance. Unfortunately upon submitting the form I 
get the same exception again ("No get method defined for class: class 
foo.HomePage expression: street").

By the way: am I doing things "the Wicket way"? Is this how you would reuse 
parts of a form in Wicket? 



Best regards,

Bob
> Hi,
> 
> I think you need to build a CompoundPropertyModel inside the component
> itself. Override onInitialize method of AddressPanel and try with
> something like this:
> 
> @Override
>  protected void onInitialize() {
>  super.onInitialize();
>  setDefaultModel(new CompoundPropertyModel(getDefaultModel()));
>  }
> 
> 
> > Hi list,
> >
> > I've created a reusable form component for editing an address, called
> AddressPanel. It inherits from FormComponent and consists of multiple text
> fields for inputting data, instances of the component get added to a Form
> instance.
> >
> > How do I use this component together with a CompoundPropertyModel? I'm using
> the following code to add the component to the form:
> >
> > Form  form = new Form("form", new
> CompoundPropertyModel(this)); // HomePage has an instance of Person
> called person
> > form.add(new TextField("person.firstname"));
> > form.add(new AddressPanel("person.address"));
> >
> > However this gives the following exception: "Last cause: No get method
> defined for class: class foo.HomePage expression: street."
> >
> > "street" is a text field that is added to the AddressPanel. Is it possible
> to have the "street" field bound to person.address.street without renaming the
> text field inside AddressPanel? I don't want to rename it since this way I
> can't reuse the component for other entities that have addresses.
> >
> > Best regards,
> >
> > Bob
> >
> >
> > Think green - keep it on the screen.
> >
> > This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an intended
> recipient then please promptly delete this e-mail and any attachment and all
> copies and inform the sender. Thank you.
> >
> >
> >
> > -
> > 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
> 


Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.



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



Re: CompoundPropertyModel and FormComponent

2012-01-16 Thread Andrea Del Bene

Hi,

I think you need to build a CompoundPropertyModel inside the component 
itself. Override onInitialize method of AddressPanel and try with 
something like this:


@Override
protected void onInitialize() {
super.onInitialize();
setDefaultModel(new CompoundPropertyModel(getDefaultModel()));
}



Hi list,

I've created a reusable form component for editing an address, called 
AddressPanel. It inherits from FormComponent and consists of multiple text 
fields for inputting data, instances of the component get added to a Form 
instance.

How do I use this component together with a CompoundPropertyModel? I'm using 
the following code to add the component to the form:

Form  form = new Form("form", new 
CompoundPropertyModel(this)); // HomePage has an instance of Person called person
form.add(new TextField("person.firstname"));
form.add(new AddressPanel("person.address"));

However this gives the following exception: "Last cause: No get method defined for 
class: class foo.HomePage expression: street."

"street" is a text field that is added to the AddressPanel. Is it possible to have the 
"street" field bound to person.address.street without renaming the text field inside 
AddressPanel? I don't want to rename it since this way I can't reuse the component for other 
entities that have addresses.

Best regards,

Bob


Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.



-
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: CompoundPropertyModel for label?

2011-06-12 Thread Clint Checketts
You need to set the CompoundPropertyModel on the parent object. In your
example the page. Try the following code:

   customer = new Customer();
   customer.setFirstName("Jimmy");
   customer.setLastName("Dean");
   customer.getAddress().setStreet("123 Easy Street");

   myModel = new CompoundPropertyModel(customer);
   setDefaultModel(myModel); //This sets the page's model, which is
the parent to the label's in question

   add(new Label("firstName"));
   add(new Label("lastName"));
   add(new Label("street.address"))


On Sun, Jun 12, 2011 at 6:14 PM, Brian Lavender  wrote:

> Is it possible to use a compound property model for a label?
>
> I tried adding labels using the following, but when I run it,
> the label comes out with what appears to be a reference to the
> model.
>
>customer = new Customer();
>customer.setFirstName("Jimmy");
>customer.setLastName("Dean");
>customer.getAddress().setStreet("123 Easy Street");
>
>myModel = new CompoundPropertyModel(customer);
>
>firstNameLabel = new Label("firstName",myModel);
>add(firstNameLabel);
>lastNameLabel = new Label("lastName",myModel);
>add(lastNameLabel);
>add(new Label("street.address", myModel))
>
> CodeResult
> firstName from Compound Property Model
>  com.brie.dtoo.Customer@7cb44d
> lastName from Compound Property Model
> com.brie.dtoo.Customer@7cb44d
> street.address from Compound Property Model
> com.brie.dtoo.Customer@7cb44d
>
> brian
> --
> Brian Lavender
> http://www.brie.com/brian/
>
> "There are two ways of constructing a software design. One way is to
> make it so simple that there are obviously no deficiencies. And the other
> way is to make it so complicated that there are no obvious deficiencies."
>
> Professor C. A. R. Hoare
> The 1980 Turing award lecture
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: CompoundPropertyModel and Image

2011-04-23 Thread andrea del bene

Hi,

I've checked Image's source class and it seems that it doesn't support 
compound models (see comments in method initModel()).

Hi there,

I have a rather simple problem, but could find a solution yet. I wanna
combine text and an image in ONE model. The image is defined by a
ContextRelativeResource. It works all as assumed, except for the
image. Here the whole thing:

public class Team extends WebPage
{
public static class TeamMember implements Serializable
{
final String name;
final Integer age;
final ContextRelativeResource picture;
//  final PackageResource picture;

public TeamMember (final String name, final Integer age, String 
pic)
{
this.name = name;
this.age = age;
this.picture = new ContextRelativeResource ("image/" + 
pic);
}
}

public Team ()
{
CompoundPropertyModel  tm = new
CompoundPropertyModel  (reneTm) ;
setDefaultModel (tm) ;

add (new Label ("name"));  // works with string
add (new Label ("age"));   // works with Integer

add (new Image ("picture")); // DOESNT WORK??

//  Image image = new Image ("picture", tm.getObject ().picture);
//image.getDefaultModelObject () == NULL  

}
}

For the completeness, here the markup:















It seems, that Image doesnt use the CompoundPropertyModel which I set
as the default model. If I would use Label instead of Image, the
correct ContextRelativeResource will be retrieved from the model.

What did I do wrong, or how to combine text and image in one Model??

Regards,
Rene

-
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: CompoundPropertyModel deprecated in 1.5 - what is the replacement?

2011-03-09 Thread Maarten Billemont
On 09 Mar 2011, at 22:36, Brown, Berlin [GCG-PFS] wrote:

>> On 09 Mar 2011, at 22:01, Chris Colman wrote:
>>> 
>>> Sorry, CompoundPropertyModel is not deprecated in 1.5, it's 
>>> BoundCompoundPropertyModel that is.
>> 
>> Too bad :-)
>> 
>> Really, you use normal models and LDMs, or BindGen
>> (http://code.google.com/p/bindgen-wicket/) and make your code type-safe.
> 
>> 
> What is wrong with compoundpropertymodel (pre 1.5)? 

Your model object is not used in a type-safe and refactorable/compile-time 
checked (read maintainable) manner.  Read the bindget URL I linked for more 
info or perhaps more informative:

http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/

Usually though, I tend to just use normal IModels, Models, AROMs and LDMs, 
though.  Those are perfectly safe thanks to Java's generics, albeit a bit 
verbose no thanks to Java's lacking support for closures.
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: CompoundPropertyModel deprecated in 1.5 - what is the replacement?

2011-03-09 Thread Brown, Berlin [GCG-PFS]
What is wrong with compoundpropertymodel (pre 1.5)? 

-Original Message-
From: Maarten Billemont [mailto:lhun...@gmail.com] 
Sent: Wednesday, March 09, 2011 4:30 PM
To: users@wicket.apache.org
Subject: Re: CompoundPropertyModel deprecated in 1.5 - what is the
replacement?

On 09 Mar 2011, at 22:01, Chris Colman wrote:
> 
> Sorry, CompoundPropertyModel is not deprecated in 1.5, it's 
> BoundCompoundPropertyModel that is.

Too bad :-)

Really, you use normal models and LDMs, or BindGen
(http://code.google.com/p/bindgen-wicket/) and make your code type-safe.
-
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: CompoundPropertyModel deprecated in 1.5 - what is the replacement?

2011-03-09 Thread Maarten Billemont
On 09 Mar 2011, at 22:01, Chris Colman wrote:
> 
> Sorry, CompoundPropertyModel is not deprecated in 1.5, it's
> BoundCompoundPropertyModel that is.

Too bad :-)

Really, you use normal models and LDMs, or BindGen 
(http://code.google.com/p/bindgen-wicket/) and make your code type-safe.
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: CompoundPropertyModel deprecated in 1.5 - what is the replacement?

2011-03-09 Thread Chris Colman
My bad! I was had done s search on CompoundPropertyModel and
BoundCompoundPropertyModel showed up in the deprecated list but I just
saw the highlighted "CompountPropertyModel" part... =]

Sorry, CompoundPropertyModel is not deprecated in 1.5, it's
BoundCompoundPropertyModel that is.

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



Re: CompoundPropertyModel deprecated in 1.5 - what is the replacement?

2011-03-09 Thread Martin Grigorov
On Wed, Mar 9, 2011 at 9:56 AM, Coleman, Chris <
chris.cole...@thalesgroup.com.au> wrote:

> I noticed that CompoundPropertyModel is deprecated in 1.5 but I can't find
> anything relating to this on the "Migration to Wicket 1.5" page.
>
> What is meant to be used instead of this class?
>

It is not deprecated.

>
>
>
>
> DISCLAIMER:---
> This e-mail transmission and any documents, files and previous e-mail
> messages
> attached to it are private and confidential. They may contain proprietary
> or copyright
> material or information that is subject to legal professional privilege.
> They are for
> the use of the intended recipient only.  Any unauthorised viewing, use,
> disclosure,
> copying, alteration, storage or distribution of, or reliance on, this
> message is
> strictly prohibited. No part may be reproduced, adapted or transmitted
> without the
> written permission of the owner. If you have received this transmission in
> error, or
> are not an authorised recipient, please immediately notify the sender by
> return email,
> delete this message and all copies from your e-mail system, and destroy any
> printed
> copies. Receipt by anyone other than the intended recipient should not be
> deemed a
> waiver of any privilege or protection. Thales Australia does not warrant or
> represent
> that this e-mail or any documents, files and previous e-mail messages
> attached are
> error or virus free.
>
> --
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com 


Re: CompoundPropertymodel loses object after form submit

2010-06-09 Thread Manfred Bergmann

Hi.

Certainly I can.

Here is the main Panel for the case where the CompoundPropertyModel loses
the object.
The WebPage classes basically only contain one of those main panels
depending of the PageParameters which are passed into the panel as converted
to a Scala immutable Map instance.
ParameterPanel is just a plain subclass of Panel which can hold a set of
parameters.
Ah, yeah, and all the code is Scala...

-
class WeekPlanEditPanel(id: String, params: Map[String, Any]) extends
ParameterPanel(id, params) {
private val log: Logger = LoggerFactory.getLogger(this.getClass)

private val wpService =
ServiceLocator.getServiceInstance[WeekPlanService]
private val weekPlanId = getIdParam
private val wp = wpService.findById(weekPlanId).get

private val formModel = new CompoundPropertyModel[WeekPlan](wp)
private val feedback = new FeedbackPanel("feedback").setVisible(false)
private val form = new Form[WeekPlan]("editForm", formModel) {
override def onError: Unit = feedback.setVisible(true)
}
form.add(new WeekPlanDataInputPanel("dataPanel", formModel, true))
form.add(new Button("saveButton") {
override def onSubmit: Unit = {
try {
wpService.update(wp)
info("Speichern erfolgreich!")
formModel.setObject(wp)// !!! explicit set of object
necessary
} catch {
case e: Exception => log.error("Error on saving weekplan
entry!", e)
error("Fehler beim Speichern des Eintrages: " +
e.getMessage)
}
feedback.setVisible(true)
}
})
form.add(new Button("deleteButton") {
override def onSubmit: Unit = {
try {
wpService.delete(wp)
setResponsePage(classOf[WeekPlanPage], new
PageParameters("action=list"))
} catch {
case e: Exception => log.error("Error on deleting weekplan
entry!", e)
error("Fehler beim Löschen des Eintrages: " + e.getMessage)
feedback.setVisible(true)
}
}
})

add(feedback)
add(form)
}
-

And the WeekPlanDataInputPanel for sake of completeness.

-
@EditorOnly
class WeekPlanDataInputPanel(id: String, model: IModel[WeekPlan], isEdit:
Boolean) extends Panel(id) {
private val weekPlan = model.getObject

add(new AdminAdditionsInputPanel("adminAdditions", model))

add(new Label("id"))
add(new Label("creator"))
add(DateLabel.forDatePattern("dateCreated", "dd.MM. hh:mm"))
add(new WeekTargetDatePanel("targetDate", model, isEdit))
}
-

When submitting the labels in the last Panel class are displayed empty on
the page reload because model object is null. weekPlan itself however is
still a valid instance.
When setting the model object in the onSubmit handler (as in the former
Panel class) it works.



Thanks,
Manfred
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertymodel-loses-object-after-form-submit-tp2248100p2248412.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: CompoundPropertymodel loses object after form submit

2010-06-08 Thread yaniv kessler
Can you show some code?

On Wed, Jun 9, 2010 at 1:01 AM, Bergmann Manfred 
wrote:

> Hi.
>
> I experience a strange behaviour where I'm not exactly sure what I'm doing
> wrong.
> On my pages which are wrapped around some database model classes I have
> forms with CompoundPropertyModels.
> On one of five pages the form seems to lose the model object after a submit
> is done so that the page reload after the submit displays empty labels and
> fields.
> This is not the case on the other four pages/forms which basically have the
> same structure.
> I got around this problem with explicitly setting the model object again in
> the onSubmit handler which seems to work.
>
> Anyone got an explanation?
> Ahh, I'm using Wicket 1.4.9.
>
>
> Cheers,
> Manfred
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Tel: +972-77-4100977
Fax: +972-77-4100976
Mobile: +972-54-7755427

http://www.codeark.com
http://blogs.microsoft.co.il/blogs/yanush/
http://headtoscreencollision.blogspot.com


Re: CompoundPropertyModel issue

2010-03-03 Thread chinedu efoagui
you are absolutely correct. It worked perfectly thank you.

On Wed, Mar 3, 2010 at 12:07 PM, Xavier López  wrote:
> Strange. I thought the component only searches parents for a CPM if and only
> if its model is null.
>
> Have you tried doing approvalofficers.setModel(new Model()); ?
> Maybe EmployeeDropDownChoice is nulling the model somewhere in the
> constructor (calling proper super() ? ).
>
> Cheers
> Xavier
>
> 2010/3/3 chinedu efoagui 
>
>> I tried that.still did not work? Any other ideas
>> rg.apache.wicket.WicketRuntimeException: No get method defined for
>> class: class com.mw.hr.entity.leaveappempleave.LeaveappEmpleave
>> expression: approvaloficer
>>        at
>> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:445)
>>
>>
>> On Tue, Mar 2, 2010 at 5:29 PM, Xavier López  wrote:
>> > I think the Model you are passing to the constructor refers to the
>> choices
>> > Model. Try using EmployeeDropDownChoice("approvaloficer",new Model(), new
>> > Model(""));
>> >
>> > Cheers,
>> > Xavier
>> >
>> > 2010/3/2 chinedu efoagui 
>> >
>> >> hello,
>> >>
>> >> i am added a dropdownchoice to a form. The form's model is set to a
>> >> CompoundPropertyModel
>> >> as shown below
>> >> IModel zaModel=new CompoundPropertyModel(selected);
>> >> leaveform.setModel(zaModel);
>> >>
>> >> Now the dropdown shows a list of Employees
>> >>
>> >> EmployeeDropDownChoice approvalofficers=new
>> >> EmployeeDropDownChoice("approvaloficer",new Model(""));
>> >>        leaveform.add(approvalofficers);
>> >> Now when I run it gives me error that it can find the getter property
>> >> of component "approvaloficer"
>> >> Now the thing is the component is
>> >> So how do i exclude the component from the CompoundPropertyModel and
>> >> still have  it show ?
>> >> I thought i could achieve that with by passing an emppty model into
>> >> its constructor like new model?
>> >> how do i solve this??
>> >>
>> >> -
>> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> >> For additional commands, e-mail: users-h...@wicket.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > "Klein bottle for rent--inquire within."
>> >
>>
>> -
>> 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: CompoundPropertyModel issue

2010-03-03 Thread Xavier López
Strange. I thought the component only searches parents for a CPM if and only
if its model is null.

Have you tried doing approvalofficers.setModel(new Model()); ?
Maybe EmployeeDropDownChoice is nulling the model somewhere in the
constructor (calling proper super() ? ).

Cheers
Xavier

2010/3/3 chinedu efoagui 

> I tried that.still did not work? Any other ideas
> rg.apache.wicket.WicketRuntimeException: No get method defined for
> class: class com.mw.hr.entity.leaveappempleave.LeaveappEmpleave
> expression: approvaloficer
>at
> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:445)
>
>
> On Tue, Mar 2, 2010 at 5:29 PM, Xavier López  wrote:
> > I think the Model you are passing to the constructor refers to the
> choices
> > Model. Try using EmployeeDropDownChoice("approvaloficer",new Model(), new
> > Model(""));
> >
> > Cheers,
> > Xavier
> >
> > 2010/3/2 chinedu efoagui 
> >
> >> hello,
> >>
> >> i am added a dropdownchoice to a form. The form's model is set to a
> >> CompoundPropertyModel
> >> as shown below
> >> IModel zaModel=new CompoundPropertyModel(selected);
> >> leaveform.setModel(zaModel);
> >>
> >> Now the dropdown shows a list of Employees
> >>
> >> EmployeeDropDownChoice approvalofficers=new
> >> EmployeeDropDownChoice("approvaloficer",new Model(""));
> >>leaveform.add(approvalofficers);
> >> Now when I run it gives me error that it can find the getter property
> >> of component "approvaloficer"
> >> Now the thing is the component is
> >> So how do i exclude the component from the CompoundPropertyModel and
> >> still have  it show ?
> >> I thought i could achieve that with by passing an emppty model into
> >> its constructor like new model?
> >> how do i solve this??
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > "Klein bottle for rent--inquire within."
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: CompoundPropertyModel issue

2010-03-03 Thread chinedu efoagui
I tried that.still did not work? Any other ideas
rg.apache.wicket.WicketRuntimeException: No get method defined for
class: class com.mw.hr.entity.leaveappempleave.LeaveappEmpleave
expression: approvaloficer
at 
org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:445)


On Tue, Mar 2, 2010 at 5:29 PM, Xavier López  wrote:
> I think the Model you are passing to the constructor refers to the choices
> Model. Try using EmployeeDropDownChoice("approvaloficer",new Model(), new
> Model(""));
>
> Cheers,
> Xavier
>
> 2010/3/2 chinedu efoagui 
>
>> hello,
>>
>> i am added a dropdownchoice to a form. The form's model is set to a
>> CompoundPropertyModel
>> as shown below
>> IModel zaModel=new CompoundPropertyModel(selected);
>> leaveform.setModel(zaModel);
>>
>> Now the dropdown shows a list of Employees
>>
>> EmployeeDropDownChoice approvalofficers=new
>> EmployeeDropDownChoice("approvaloficer",new Model(""));
>>        leaveform.add(approvalofficers);
>> Now when I run it gives me error that it can find the getter property
>> of component "approvaloficer"
>> Now the thing is the component is
>> So how do i exclude the component from the CompoundPropertyModel and
>> still have  it show ?
>> I thought i could achieve that with by passing an emppty model into
>> its constructor like new model?
>> how do i solve this??
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
>
> --
> "Klein bottle for rent--inquire within."
>

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



Re: CompoundPropertyModel issue

2010-03-02 Thread Xavier López
I think the Model you are passing to the constructor refers to the choices
Model. Try using EmployeeDropDownChoice("approvaloficer",new Model(), new
Model(""));

Cheers,
Xavier

2010/3/2 chinedu efoagui 

> hello,
>
> i am added a dropdownchoice to a form. The form's model is set to a
> CompoundPropertyModel
> as shown below
> IModel zaModel=new CompoundPropertyModel(selected);
> leaveform.setModel(zaModel);
>
> Now the dropdown shows a list of Employees
>
> EmployeeDropDownChoice approvalofficers=new
> EmployeeDropDownChoice("approvaloficer",new Model(""));
>leaveform.add(approvalofficers);
> Now when I run it gives me error that it can find the getter property
> of component "approvaloficer"
> Now the thing is the component is
> So how do i exclude the component from the CompoundPropertyModel and
> still have  it show ?
> I thought i could achieve that with by passing an emppty model into
> its constructor like new model?
> how do i solve this??
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
"Klein bottle for rent--inquire within."


Re: CompoundPropertyModel

2009-11-29 Thread Николай Кучумов
To come up with a decision, I can propose you to catch this special
exception, then count all JSESSIONID cookies, and, if there are several of
them, delete the stale JSESSIONID cookies, and then try to run the form
submission cycle again programmaticaly.

2009/11/29 Николай Кучумов 

> Also I've noticed, that if i submit the form, then redeploy the WAR, and
> then refresh the submitted page, it throws the exception described above.
> And hitting Ctrl + F5 doesn't fix the issue - you are unable to submit the
> form anymore...
> The reason is that it (at least, Firefox 3) accumulates JSESSIONID cookies
> - I've seen even three of them simultaneously.
> After I delete these stale JSESSIONID cookies, I'm able to submit the form
> again.
> I'm not sure, what a decision could be.
> Maybe it is a well known bug.
> Just reporting it to you.
>
>
> 2009/11/28 Николай Кучумов 
>
> Today I've finally worked out the cause of the error - that was the NginX
>> caching server which was somehow caching data.
>> It was set up incorrectly.
>> Today I've corrected my NginX configuration files, and everything works
>> now, even with the bookmarks.
>>
>> 2009/11/20 Николай Кучумов 
>>
>> Hello, Alex, Jeremy and others.
>>>
>>> That's weird. Really weird.
>>> You know what?
>>> Seems that my browser was causing the error...
>>> If i open my site via a bookmark, it outputs the error.
>>> However if i open a new tab and type in the URL manually, the error
>>> doesn't appear.
>>> So, an advice to all of the Firefox users: don't bookmark the link to
>>> your web application!
>>>
>>>
>>> 2009/11/14 Alex Rass 
>>>
>>> Kolya,
>>>>
>>>> 2 things:
>>>> 1) If you still have the old setup:
>>>>  Try stopping server, deploying your stuff to it, starting server.
>>>>  I've had issues with redeploying at runtime (hot deploy) with Tomcat
>>>> (which is what Glassfish is based on).  This is where Jeremy's advice to
>>>> run
>>>> Jetty is a good idea.
>>>>
>>>> 2) Make sure that you refresh the form in your web browser before you
>>>> try to
>>>> enter data and submit.  Wicket needs to do stuff to that form before you
>>>> can
>>>> submit it and if you keep same browser open between deployments, you are
>>>> sending data back to wicket that it knows nothing about, so it blows up
>>>> with
>>>> pageexpired.
>>>>
>>>> The fact that you don't get serialization errors in the log (if it
>>>> wasn't
>>>> serialized) is b/c it didn't get that far yet, so problems are
>>>> elsewhere.
>>>>
>>>> Hope this helps,
>>>> - Alex.
>>>>
>>>> -Original Message-
>>>> From: Николай Кучумов [mailto:kuchum...@gmail.com]
>>>> Sent: Saturday, November 14, 2009 9:33 AM
>>>> To: users@wicket.apache.org
>>>> Subject: Re: CompoundPropertyModel
>>>>
>>>> Hi, Jeremy.
>>>> No, the log contained only this error...
>>>> But to be honest, although it didn't fix the error, your advice is still
>>>> valuable, because not all of the classes were Serializable.
>>>> And you know what?
>>>> I think I'll reinstall my application server.
>>>> I used Glassfish 2 before, and this time I tried Glassfish 3, but it
>>>> appeared to be a bitch...
>>>> It hangs oftenly and operates strangely...
>>>> So maybe it somehow messes with the sessions...
>>>> I'll install Glassfish 2 back then, when I have more time for this
>>>> (maybe
>>>> tomorrow), and then I'll post the results here.
>>>> Thanks for your reply.
>>>>
>>>> On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson <
>>>> jer...@wickettraining.com
>>>> > wrote:
>>>>
>>>> > Do both Person and Credentials (and everything else Person holds on
>>>> to)
>>>> > implement Serializable?
>>>> >
>>>> > Watch the logs to see if there are serialization errors.  It's a
>>>> problem
>>>> of
>>>> > the page not being in the session - which means it either didn't make
>>>> it
>>>> > there or the session is somehow gone.
>>>> >
>>>> > --
>>>&

Re: CompoundPropertyModel

2009-11-29 Thread Николай Кучумов
Also I've noticed, that if i submit the form, then redeploy the WAR, and
then refresh the submitted page, it throws the exception described above.
And hitting Ctrl + F5 doesn't fix the issue - you are unable to submit the
form anymore...
The reason is that it (at least, Firefox 3) accumulates JSESSIONID cookies -
I've seen even three of them simultaneously.
After I delete these stale JSESSIONID cookies, I'm able to submit the form
again.
I'm not sure, what a decision could be.
Maybe it is a well known bug.
Just reporting it to you.


2009/11/28 Николай Кучумов 

> Today I've finally worked out the cause of the error - that was the NginX
> caching server which was somehow caching data.
> It was set up incorrectly.
> Today I've corrected my NginX configuration files, and everything works
> now, even with the bookmarks.
>
> 2009/11/20 Николай Кучумов 
>
> Hello, Alex, Jeremy and others.
>>
>> That's weird. Really weird.
>> You know what?
>> Seems that my browser was causing the error...
>> If i open my site via a bookmark, it outputs the error.
>> However if i open a new tab and type in the URL manually, the error
>> doesn't appear.
>> So, an advice to all of the Firefox users: don't bookmark the link to your
>> web application!
>>
>>
>> 2009/11/14 Alex Rass 
>>
>> Kolya,
>>>
>>> 2 things:
>>> 1) If you still have the old setup:
>>>  Try stopping server, deploying your stuff to it, starting server.
>>>  I've had issues with redeploying at runtime (hot deploy) with Tomcat
>>> (which is what Glassfish is based on).  This is where Jeremy's advice to
>>> run
>>> Jetty is a good idea.
>>>
>>> 2) Make sure that you refresh the form in your web browser before you try
>>> to
>>> enter data and submit.  Wicket needs to do stuff to that form before you
>>> can
>>> submit it and if you keep same browser open between deployments, you are
>>> sending data back to wicket that it knows nothing about, so it blows up
>>> with
>>> pageexpired.
>>>
>>> The fact that you don't get serialization errors in the log (if it wasn't
>>> serialized) is b/c it didn't get that far yet, so problems are elsewhere.
>>>
>>> Hope this helps,
>>> - Alex.
>>>
>>> -Original Message-
>>> From: Николай Кучумов [mailto:kuchum...@gmail.com]
>>> Sent: Saturday, November 14, 2009 9:33 AM
>>> To: users@wicket.apache.org
>>> Subject: Re: CompoundPropertyModel
>>>
>>> Hi, Jeremy.
>>> No, the log contained only this error...
>>> But to be honest, although it didn't fix the error, your advice is still
>>> valuable, because not all of the classes were Serializable.
>>> And you know what?
>>> I think I'll reinstall my application server.
>>> I used Glassfish 2 before, and this time I tried Glassfish 3, but it
>>> appeared to be a bitch...
>>> It hangs oftenly and operates strangely...
>>> So maybe it somehow messes with the sessions...
>>> I'll install Glassfish 2 back then, when I have more time for this (maybe
>>> tomorrow), and then I'll post the results here.
>>> Thanks for your reply.
>>>
>>> On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson <
>>> jer...@wickettraining.com
>>> > wrote:
>>>
>>> > Do both Person and Credentials (and everything else Person holds on to)
>>> > implement Serializable?
>>> >
>>> > Watch the logs to see if there are serialization errors.  It's a
>>> problem
>>> of
>>> > the page not being in the session - which means it either didn't make
>>> it
>>> > there or the session is somehow gone.
>>> >
>>> > --
>>> > Jeremy Thomerson
>>> > http://www.wickettraining.com
>>> >
>>> >
>>> >
>>> > On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов >> > >wrote:
>>> >
>>> > > Hello.
>>> > > I have a "Person" class, describing a person, which has a member
>>> > > "credentials" of type "Credentials" (username/password).
>>> > > I tried to make a registration page in this way:
>>> > >
>>> > > Page
>>> > > {
>>> > >super();
>>> > >
>>> > >Person person = [create a person with empty credentials]

Re: CompoundPropertyModel

2009-11-28 Thread Николай Кучумов
Today I've finally worked out the cause of the error - that was the NginX
caching server which was somehow caching data.
It was set up incorrectly.
Today I've corrected my NginX configuration files, and everything works now,
even with the bookmarks.

2009/11/20 Николай Кучумов 

> Hello, Alex, Jeremy and others.
>
> That's weird. Really weird.
> You know what?
> Seems that my browser was causing the error...
> If i open my site via a bookmark, it outputs the error.
> However if i open a new tab and type in the URL manually, the error doesn't
> appear.
> So, an advice to all of the Firefox users: don't bookmark the link to your
> web application!
>
>
> 2009/11/14 Alex Rass 
>
> Kolya,
>>
>> 2 things:
>> 1) If you still have the old setup:
>>  Try stopping server, deploying your stuff to it, starting server.
>>  I've had issues with redeploying at runtime (hot deploy) with Tomcat
>> (which is what Glassfish is based on).  This is where Jeremy's advice to
>> run
>> Jetty is a good idea.
>>
>> 2) Make sure that you refresh the form in your web browser before you try
>> to
>> enter data and submit.  Wicket needs to do stuff to that form before you
>> can
>> submit it and if you keep same browser open between deployments, you are
>> sending data back to wicket that it knows nothing about, so it blows up
>> with
>> pageexpired.
>>
>> The fact that you don't get serialization errors in the log (if it wasn't
>> serialized) is b/c it didn't get that far yet, so problems are elsewhere.
>>
>> Hope this helps,
>> - Alex.
>>
>> -Original Message-
>> From: Николай Кучумов [mailto:kuchum...@gmail.com]
>> Sent: Saturday, November 14, 2009 9:33 AM
>> To: users@wicket.apache.org
>> Subject: Re: CompoundPropertyModel
>>
>> Hi, Jeremy.
>> No, the log contained only this error...
>> But to be honest, although it didn't fix the error, your advice is still
>> valuable, because not all of the classes were Serializable.
>> And you know what?
>> I think I'll reinstall my application server.
>> I used Glassfish 2 before, and this time I tried Glassfish 3, but it
>> appeared to be a bitch...
>> It hangs oftenly and operates strangely...
>> So maybe it somehow messes with the sessions...
>> I'll install Glassfish 2 back then, when I have more time for this (maybe
>> tomorrow), and then I'll post the results here.
>> Thanks for your reply.
>>
>> On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson <
>> jer...@wickettraining.com
>> > wrote:
>>
>> > Do both Person and Credentials (and everything else Person holds on to)
>> > implement Serializable?
>> >
>> > Watch the logs to see if there are serialization errors.  It's a problem
>> of
>> > the page not being in the session - which means it either didn't make it
>> > there or the session is somehow gone.
>> >
>> > --
>> > Jeremy Thomerson
>> > http://www.wickettraining.com
>> >
>> >
>> >
>> > On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов > > >wrote:
>> >
>> > > Hello.
>> > > I have a "Person" class, describing a person, which has a member
>> > > "credentials" of type "Credentials" (username/password).
>> > > I tried to make a registration page in this way:
>> > >
>> > > Page
>> > > {
>> > >super();
>> > >
>> > >Person person = [create a person with empty credentials];
>> > >
>> > >Form form = new Form("form", new CompoundPropertyModel(person));
>> > >
>> > >add(form);
>> > >
>> > >form.add(new TextField("familyName"));
>> > >form.add(new TextField("givenName"));
>> > >
>> > >form.add(new TextField("credentials.userName"));
>> > >form.add(new TextField("credentials.passWord"));
>> > >
>> > >// also add a submit button
>> > > }
>> > >
>> > > And now when I push the "Submit" button, it outputs this error:
>> > >
>> > > org.apache.wicket.protocol.http.PageExpiredException: Cannot find the
>> > > rendered page in session
>> [pagemap=null,componentPath=0,versionNumber=0]
>> > >
>> > > I like the idea of compound object model, and I wouldn't like to
>> deprive
>> > > myself from using it just because of this strange error...
>> > > Can you give me a hint on what have I done wrong in the code above?
>> > >
>> >
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>


Re: CompoundPropertyModel

2009-11-20 Thread Николай Кучумов
Hello, Alex, Jeremy and others.

That's weird. Really weird.
You know what?
Seems that my browser was causing the error...
If i open my site via a bookmark, it outputs the error.
However if i open a new tab and type in the URL manually, the error doesn't
appear.
So, an advice to all of the Firefox users: don't bookmark the link to your
web application!


2009/11/14 Alex Rass 

> Kolya,
>
> 2 things:
> 1) If you still have the old setup:
>  Try stopping server, deploying your stuff to it, starting server.
>  I've had issues with redeploying at runtime (hot deploy) with Tomcat
> (which is what Glassfish is based on).  This is where Jeremy's advice to
> run
> Jetty is a good idea.
>
> 2) Make sure that you refresh the form in your web browser before you try
> to
> enter data and submit.  Wicket needs to do stuff to that form before you
> can
> submit it and if you keep same browser open between deployments, you are
> sending data back to wicket that it knows nothing about, so it blows up
> with
> pageexpired.
>
> The fact that you don't get serialization errors in the log (if it wasn't
> serialized) is b/c it didn't get that far yet, so problems are elsewhere.
>
> Hope this helps,
> - Alex.
>
> -Original Message-
> From: Николай Кучумов [mailto:kuchum...@gmail.com]
> Sent: Saturday, November 14, 2009 9:33 AM
> To: users@wicket.apache.org
> Subject: Re: CompoundPropertyModel
>
> Hi, Jeremy.
> No, the log contained only this error...
> But to be honest, although it didn't fix the error, your advice is still
> valuable, because not all of the classes were Serializable.
> And you know what?
> I think I'll reinstall my application server.
> I used Glassfish 2 before, and this time I tried Glassfish 3, but it
> appeared to be a bitch...
> It hangs oftenly and operates strangely...
> So maybe it somehow messes with the sessions...
> I'll install Glassfish 2 back then, when I have more time for this (maybe
> tomorrow), and then I'll post the results here.
> Thanks for your reply.
>
> On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson <
> jer...@wickettraining.com
> > wrote:
>
> > Do both Person and Credentials (and everything else Person holds on to)
> > implement Serializable?
> >
> > Watch the logs to see if there are serialization errors.  It's a problem
> of
> > the page not being in the session - which means it either didn't make it
> > there or the session is somehow gone.
> >
> > --
> > Jeremy Thomerson
> > http://www.wickettraining.com
> >
> >
> >
> > On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов  > >wrote:
> >
> > > Hello.
> > > I have a "Person" class, describing a person, which has a member
> > > "credentials" of type "Credentials" (username/password).
> > > I tried to make a registration page in this way:
> > >
> > > Page
> > > {
> > >super();
> > >
> > >Person person = [create a person with empty credentials];
> > >
> > >Form form = new Form("form", new CompoundPropertyModel(person));
> > >
> > >add(form);
> > >
> > >form.add(new TextField("familyName"));
> > >form.add(new TextField("givenName"));
> > >
> > >form.add(new TextField("credentials.userName"));
> > >form.add(new TextField("credentials.passWord"));
> > >
> > >// also add a submit button
> > > }
> > >
> > > And now when I push the "Submit" button, it outputs this error:
> > >
> > > org.apache.wicket.protocol.http.PageExpiredException: Cannot find the
> > > rendered page in session [pagemap=null,componentPath=0,versionNumber=0]
> > >
> > > I like the idea of compound object model, and I wouldn't like to
> deprive
> > > myself from using it just because of this strange error...
> > > Can you give me a hint on what have I done wrong in the code above?
> > >
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


RE: CompoundPropertyModel

2009-11-14 Thread Alex Rass
Kolya,

2 things:
1) If you still have the old setup:
  Try stopping server, deploying your stuff to it, starting server.
  I've had issues with redeploying at runtime (hot deploy) with Tomcat
(which is what Glassfish is based on).  This is where Jeremy's advice to run
Jetty is a good idea.

2) Make sure that you refresh the form in your web browser before you try to
enter data and submit.  Wicket needs to do stuff to that form before you can
submit it and if you keep same browser open between deployments, you are
sending data back to wicket that it knows nothing about, so it blows up with
pageexpired.

The fact that you don't get serialization errors in the log (if it wasn't
serialized) is b/c it didn't get that far yet, so problems are elsewhere.

Hope this helps,
- Alex. 

-Original Message-
From: Николай Кучумов [mailto:kuchum...@gmail.com] 
Sent: Saturday, November 14, 2009 9:33 AM
To: users@wicket.apache.org
Subject: Re: CompoundPropertyModel

Hi, Jeremy.
No, the log contained only this error...
But to be honest, although it didn't fix the error, your advice is still
valuable, because not all of the classes were Serializable.
And you know what?
I think I'll reinstall my application server.
I used Glassfish 2 before, and this time I tried Glassfish 3, but it
appeared to be a bitch...
It hangs oftenly and operates strangely...
So maybe it somehow messes with the sessions...
I'll install Glassfish 2 back then, when I have more time for this (maybe
tomorrow), and then I'll post the results here.
Thanks for your reply.

On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson  wrote:

> Do both Person and Credentials (and everything else Person holds on to)
> implement Serializable?
>
> Watch the logs to see if there are serialization errors.  It's a problem
of
> the page not being in the session - which means it either didn't make it
> there or the session is somehow gone.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов  >wrote:
>
> > Hello.
> > I have a "Person" class, describing a person, which has a member
> > "credentials" of type "Credentials" (username/password).
> > I tried to make a registration page in this way:
> >
> > Page
> > {
> >super();
> >
> >Person person = [create a person with empty credentials];
> >
> >Form form = new Form("form", new CompoundPropertyModel(person));
> >
> >add(form);
> >
> >form.add(new TextField("familyName"));
> >form.add(new TextField("givenName"));
> >
> >form.add(new TextField("credentials.userName"));
> >form.add(new TextField("credentials.passWord"));
> >
> >// also add a submit button
> > }
> >
> > And now when I push the "Submit" button, it outputs this error:
> >
> > org.apache.wicket.protocol.http.PageExpiredException: Cannot find the
> > rendered page in session [pagemap=null,componentPath=0,versionNumber=0]
> >
> > I like the idea of compound object model, and I wouldn't like to deprive
> > myself from using it just because of this strange error...
> > Can you give me a hint on what have I done wrong in the code above?
> >
>


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



Re: CompoundPropertyModel

2009-11-14 Thread Jeremy Thomerson
Try running your project in Jetty for development (you can use the Maven
quickstart to help you get started).  It's usually much easier to get
running and see what's going on.  It also allows for very easy on-the-fly
changes and reloading.

--
Jeremy Thomerson
http://www.wickettraining.com



On Sat, Nov 14, 2009 at 8:32 AM, Николай Кучумов wrote:

> Hi, Jeremy.
> No, the log contained only this error...
> But to be honest, although it didn't fix the error, your advice is still
> valuable, because not all of the classes were Serializable.
> And you know what?
> I think I'll reinstall my application server.
> I used Glassfish 2 before, and this time I tried Glassfish 3, but it
> appeared to be a bitch...
> It hangs oftenly and operates strangely...
> So maybe it somehow messes with the sessions...
> I'll install Glassfish 2 back then, when I have more time for this (maybe
> tomorrow), and then I'll post the results here.
> Thanks for your reply.
>
> On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson <
> jer...@wickettraining.com
> > wrote:
>
> > Do both Person and Credentials (and everything else Person holds on to)
> > implement Serializable?
> >
> > Watch the logs to see if there are serialization errors.  It's a problem
> of
> > the page not being in the session - which means it either didn't make it
> > there or the session is somehow gone.
> >
> > --
> > Jeremy Thomerson
> > http://www.wickettraining.com
> >
> >
> >
> > On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов  > >wrote:
> >
> > > Hello.
> > > I have a "Person" class, describing a person, which has a member
> > > "credentials" of type "Credentials" (username/password).
> > > I tried to make a registration page in this way:
> > >
> > > Page
> > > {
> > >super();
> > >
> > >Person person = [create a person with empty credentials];
> > >
> > >Form form = new Form("form", new CompoundPropertyModel(person));
> > >
> > >add(form);
> > >
> > >form.add(new TextField("familyName"));
> > >form.add(new TextField("givenName"));
> > >
> > >form.add(new TextField("credentials.userName"));
> > >form.add(new TextField("credentials.passWord"));
> > >
> > >// also add a submit button
> > > }
> > >
> > > And now when I push the "Submit" button, it outputs this error:
> > >
> > > org.apache.wicket.protocol.http.PageExpiredException: Cannot find the
> > > rendered page in session [pagemap=null,componentPath=0,versionNumber=0]
> > >
> > > I like the idea of compound object model, and I wouldn't like to
> deprive
> > > myself from using it just because of this strange error...
> > > Can you give me a hint on what have I done wrong in the code above?
> > >
> >
>


Re: CompoundPropertyModel

2009-11-14 Thread Николай Кучумов
Hi, Jeremy.
No, the log contained only this error...
But to be honest, although it didn't fix the error, your advice is still
valuable, because not all of the classes were Serializable.
And you know what?
I think I'll reinstall my application server.
I used Glassfish 2 before, and this time I tried Glassfish 3, but it
appeared to be a bitch...
It hangs oftenly and operates strangely...
So maybe it somehow messes with the sessions...
I'll install Glassfish 2 back then, when I have more time for this (maybe
tomorrow), and then I'll post the results here.
Thanks for your reply.

On Sat, Nov 14, 2009 at 5:11 PM, Jeremy Thomerson  wrote:

> Do both Person and Credentials (and everything else Person holds on to)
> implement Serializable?
>
> Watch the logs to see if there are serialization errors.  It's a problem of
> the page not being in the session - which means it either didn't make it
> there or the session is somehow gone.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов  >wrote:
>
> > Hello.
> > I have a "Person" class, describing a person, which has a member
> > "credentials" of type "Credentials" (username/password).
> > I tried to make a registration page in this way:
> >
> > Page
> > {
> >super();
> >
> >Person person = [create a person with empty credentials];
> >
> >Form form = new Form("form", new CompoundPropertyModel(person));
> >
> >add(form);
> >
> >form.add(new TextField("familyName"));
> >form.add(new TextField("givenName"));
> >
> >form.add(new TextField("credentials.userName"));
> >form.add(new TextField("credentials.passWord"));
> >
> >// also add a submit button
> > }
> >
> > And now when I push the "Submit" button, it outputs this error:
> >
> > org.apache.wicket.protocol.http.PageExpiredException: Cannot find the
> > rendered page in session [pagemap=null,componentPath=0,versionNumber=0]
> >
> > I like the idea of compound object model, and I wouldn't like to deprive
> > myself from using it just because of this strange error...
> > Can you give me a hint on what have I done wrong in the code above?
> >
>


Re: CompoundPropertyModel

2009-11-14 Thread Jeremy Thomerson
Do both Person and Credentials (and everything else Person holds on to)
implement Serializable?

Watch the logs to see if there are serialization errors.  It's a problem of
the page not being in the session - which means it either didn't make it
there or the session is somehow gone.

--
Jeremy Thomerson
http://www.wickettraining.com



On Sat, Nov 14, 2009 at 7:26 AM, Николай Кучумов wrote:

> Hello.
> I have a "Person" class, describing a person, which has a member
> "credentials" of type "Credentials" (username/password).
> I tried to make a registration page in this way:
>
> Page
> {
>super();
>
>Person person = [create a person with empty credentials];
>
>Form form = new Form("form", new CompoundPropertyModel(person));
>
>add(form);
>
>form.add(new TextField("familyName"));
>form.add(new TextField("givenName"));
>
>form.add(new TextField("credentials.userName"));
>form.add(new TextField("credentials.passWord"));
>
>// also add a submit button
> }
>
> And now when I push the "Submit" button, it outputs this error:
>
> org.apache.wicket.protocol.http.PageExpiredException: Cannot find the
> rendered page in session [pagemap=null,componentPath=0,versionNumber=0]
>
> I like the idea of compound object model, and I wouldn't like to deprive
> myself from using it just because of this strange error...
> Can you give me a hint on what have I done wrong in the code above?
>


Re: CompoundPropertyModel and nested DataView

2009-06-25 Thread Jeremy Thomerson
And, no, this is not the ideal place for a CPM.  A CPM is most
commonly used on a form that has many form components below it that
directly edit items off of the form's model.  ie:


new Form(new CPM(new Person()))

form.add(new Label("firstName"))   <--- by using a CPM, you save
creating your own property model here

form.add(new Label("lastName"))   <--- by using a CPM, you save
creating your own property model here

I have been using Wicket for several years, and I hardly ever use a
CPM.  It's a shortcut that you can use if you choose to do so.  But
it's nothing more than that.  Like Igor said, you'll be better served
by understanding models first rather than understanding CPM.

--
Jeremy Thomerson
http://www.wickettraining.com




On Thu, Jun 25, 2009 at 6:22 PM, Jeremy
Thomerson wrote:
> The problem in your example is not the CPM, but your data provider -
> where does it get it's list of items from?
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
>
> On Thu, Jun 25, 2009 at 6:07 PM, Hubbard, Bobby 
> wrote:
>> Does that mean what I am trying to do is not suited for 
>> CompoundPropertyModel? :) Can you point me to some documentation that might 
>> help me understand it better?
>>
>> -Original Message-
>> From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
>> Sent: Thursday, June 25, 2009 11:22 AM
>> To: users@wicket.apache.org
>> Subject: Re: CompoundPropertyModel and nested DataView
>>
>> if you are a newbie do not use CPM it is a shortcut model more suited
>> for users who know and understand models well.
>>
>> -igor
>>
>> On Wed, Jun 24, 2009 at 5:35 PM, Hubbard, Bobby 
>> wrote:
>>> I am a Wicket newbie and am currently struggling with
>>> CompoundPropertyModel. I have found a lot on the list about
>>> CompoundPropertyModel but not regarding this specific issue. I am
>>> building a shopping cart. I have placed the cart's form inside a panel
>>> and the cart items (via DataView) are inside the form. ShoppingCart is a
>>> model that I would like to use to represent the current state of the
>>> entire cart. It contains a array of ShoppingCartItem 's. However, when
>>> running this, cartItems never gets set on the ShoppingCart model. While
>>> debugging, cartItems is a child of the panelForm, but never gets
>>> populated on the ShoppingCart pojo via CompoundPropertyModel. The form
>>> does persist and if I traverse the panelForm object I could figure out
>>> how to get to the ShoppingCartItem's...but I'd rather not. J
>>>
>>>
>>>
>>> What am I missing? Is there a better way to do this? See code attached
>>> below.
>>>
>>>
>>>
>>> Thanks!!
>>>
>>>
>>>
>>> 
>>>
>>> ...
>>>
>>> public CartPanel(String id) {
>>>
>>>      super(id);
>>>
>>>      Form panelForm = new Form("panelForm", new
>>> CompoundPropertyModel(new ShoppingCart())) {
>>>
>>>           �...@override
>>>
>>>            protected void onSubmit() {
>>>
>>>                  // need to rewrite cookie on update
>>>
>>>                  ShoppingCart cart = (ShoppingCart) getModelObject();
>>>
>>>                  System.out.println(cart.getCartItems());// check if
>>> cart items got populated
>>>
>>>            }
>>>
>>>      };
>>>
>>>      add(panelForm);
>>>
>>>
>>>
>>>      IDataProvider dataProvider = new ShoppingCartItemsProvider();
>>>
>>>      DataView dataView = new DataView("cartItems", dataProvider) {
>>>
>>>           �...@override
>>>
>>>            protected void populateItem(final Item item) {
>>>
>>>                  final ShoppingCartItem cartItem = (ShoppingCartItem)
>>> item
>>>
>>>                        .getModelObject();
>>>
>>>                  item.add(new Label("itemName", cartItem.getName()));
>>>
>>>                  item.add(new TextField("quantity", new
>>> ShoppingCartItemModel(
>>>
>>>                        new Model(cartItem),
>>> ShoppingCartItemType.QUANTITY)));
>>>
>>>            }
>>>
>>>      };
>>>
>>>      // add general text labels and buttons to the cart
>>>
>>>      addFieldsAndButtons(panelForm);
&

Re: CompoundPropertyModel and nested DataView

2009-06-25 Thread Jeremy Thomerson
The problem in your example is not the CPM, but your data provider -
where does it get it's list of items from?

--
Jeremy Thomerson
http://www.wickettraining.com




On Thu, Jun 25, 2009 at 6:07 PM, Hubbard, Bobby wrote:
> Does that mean what I am trying to do is not suited for 
> CompoundPropertyModel? :) Can you point me to some documentation that might 
> help me understand it better?
>
> -Original Message-
> From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
> Sent: Thursday, June 25, 2009 11:22 AM
> To: users@wicket.apache.org
> Subject: Re: CompoundPropertyModel and nested DataView
>
> if you are a newbie do not use CPM it is a shortcut model more suited
> for users who know and understand models well.
>
> -igor
>
> On Wed, Jun 24, 2009 at 5:35 PM, Hubbard, Bobby 
> wrote:
>> I am a Wicket newbie and am currently struggling with
>> CompoundPropertyModel. I have found a lot on the list about
>> CompoundPropertyModel but not regarding this specific issue. I am
>> building a shopping cart. I have placed the cart's form inside a panel
>> and the cart items (via DataView) are inside the form. ShoppingCart is a
>> model that I would like to use to represent the current state of the
>> entire cart. It contains a array of ShoppingCartItem 's. However, when
>> running this, cartItems never gets set on the ShoppingCart model. While
>> debugging, cartItems is a child of the panelForm, but never gets
>> populated on the ShoppingCart pojo via CompoundPropertyModel. The form
>> does persist and if I traverse the panelForm object I could figure out
>> how to get to the ShoppingCartItem's...but I'd rather not. J
>>
>>
>>
>> What am I missing? Is there a better way to do this? See code attached
>> below.
>>
>>
>>
>> Thanks!!
>>
>>
>>
>> 
>>
>> ...
>>
>> public CartPanel(String id) {
>>
>>      super(id);
>>
>>      Form panelForm = new Form("panelForm", new
>> CompoundPropertyModel(new ShoppingCart())) {
>>
>>           �...@override
>>
>>            protected void onSubmit() {
>>
>>                  // need to rewrite cookie on update
>>
>>                  ShoppingCart cart = (ShoppingCart) getModelObject();
>>
>>                  System.out.println(cart.getCartItems());// check if
>> cart items got populated
>>
>>            }
>>
>>      };
>>
>>      add(panelForm);
>>
>>
>>
>>      IDataProvider dataProvider = new ShoppingCartItemsProvider();
>>
>>      DataView dataView = new DataView("cartItems", dataProvider) {
>>
>>           �...@override
>>
>>            protected void populateItem(final Item item) {
>>
>>                  final ShoppingCartItem cartItem = (ShoppingCartItem)
>> item
>>
>>                        .getModelObject();
>>
>>                  item.add(new Label("itemName", cartItem.getName()));
>>
>>                  item.add(new TextField("quantity", new
>> ShoppingCartItemModel(
>>
>>                        new Model(cartItem),
>> ShoppingCartItemType.QUANTITY)));
>>
>>            }
>>
>>      };
>>
>>      // add general text labels and buttons to the cart
>>
>>      addFieldsAndButtons(panelForm);
>>
>>      panelForm.add(dataView);
>>
>> }...
>>
>> 
>>
>>
>>
>> Thanks!!
>>
>>
>>
>>
>> --
>> This e-mail and any attachments may contain confidential material for the 
>> sole use of the intended recipient. If you are not the intended recipient, 
>> please be aware that any disclosure, copying, distribution or use of this 
>> e-mail or any attachment is prohibited. If you have received this e-mail in 
>> error, please contact the sender and delete all copies.
>> Thank you for your cooperation.
>>
>
> -
> 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: CompoundPropertyModel and nested DataView

2009-06-25 Thread Hubbard, Bobby
Does that mean what I am trying to do is not suited for CompoundPropertyModel? 
:) Can you point me to some documentation that might help me understand it 
better?

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Thursday, June 25, 2009 11:22 AM
To: users@wicket.apache.org
Subject: Re: CompoundPropertyModel and nested DataView

if you are a newbie do not use CPM it is a shortcut model more suited
for users who know and understand models well.

-igor

On Wed, Jun 24, 2009 at 5:35 PM, Hubbard, Bobby wrote:
> I am a Wicket newbie and am currently struggling with
> CompoundPropertyModel. I have found a lot on the list about
> CompoundPropertyModel but not regarding this specific issue. I am
> building a shopping cart. I have placed the cart's form inside a panel
> and the cart items (via DataView) are inside the form. ShoppingCart is a
> model that I would like to use to represent the current state of the
> entire cart. It contains a array of ShoppingCartItem 's. However, when
> running this, cartItems never gets set on the ShoppingCart model. While
> debugging, cartItems is a child of the panelForm, but never gets
> populated on the ShoppingCart pojo via CompoundPropertyModel. The form
> does persist and if I traverse the panelForm object I could figure out
> how to get to the ShoppingCartItem's...but I'd rather not. J
>
>
>
> What am I missing? Is there a better way to do this? See code attached
> below.
>
>
>
> Thanks!!
>
>
>
> 
>
> ...
>
> public CartPanel(String id) {
>
>      super(id);
>
>      Form panelForm = new Form("panelForm", new
> CompoundPropertyModel(new ShoppingCart())) {
>
>           �...@override
>
>            protected void onSubmit() {
>
>                  // need to rewrite cookie on update
>
>                  ShoppingCart cart = (ShoppingCart) getModelObject();
>
>                  System.out.println(cart.getCartItems());// check if
> cart items got populated
>
>            }
>
>      };
>
>      add(panelForm);
>
>
>
>      IDataProvider dataProvider = new ShoppingCartItemsProvider();
>
>      DataView dataView = new DataView("cartItems", dataProvider) {
>
>           �...@override
>
>            protected void populateItem(final Item item) {
>
>                  final ShoppingCartItem cartItem = (ShoppingCartItem)
> item
>
>                        .getModelObject();
>
>                  item.add(new Label("itemName", cartItem.getName()));
>
>                  item.add(new TextField("quantity", new
> ShoppingCartItemModel(
>
>                        new Model(cartItem),
> ShoppingCartItemType.QUANTITY)));
>
>            }
>
>      };
>
>      // add general text labels and buttons to the cart
>
>      addFieldsAndButtons(panelForm);
>
>      panelForm.add(dataView);
>
> }...
>
> 
>
>
>
> Thanks!!
>
>
>
>
> --
> This e-mail and any attachments may contain confidential material for the 
> sole use of the intended recipient. If you are not the intended recipient, 
> please be aware that any disclosure, copying, distribution or use of this 
> e-mail or any attachment is prohibited. If you have received this e-mail in 
> error, please contact the sender and delete all copies.
> Thank you for your cooperation.
>

-
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: CompoundPropertyModel and nested DataView

2009-06-25 Thread Igor Vaynberg
if you are a newbie do not use CPM it is a shortcut model more suited
for users who know and understand models well.

-igor

On Wed, Jun 24, 2009 at 5:35 PM, Hubbard, Bobby wrote:
> I am a Wicket newbie and am currently struggling with
> CompoundPropertyModel. I have found a lot on the list about
> CompoundPropertyModel but not regarding this specific issue. I am
> building a shopping cart. I have placed the cart's form inside a panel
> and the cart items (via DataView) are inside the form. ShoppingCart is a
> model that I would like to use to represent the current state of the
> entire cart. It contains a array of ShoppingCartItem 's. However, when
> running this, cartItems never gets set on the ShoppingCart model. While
> debugging, cartItems is a child of the panelForm, but never gets
> populated on the ShoppingCart pojo via CompoundPropertyModel. The form
> does persist and if I traverse the panelForm object I could figure out
> how to get to the ShoppingCartItem's...but I'd rather not. J
>
>
>
> What am I missing? Is there a better way to do this? See code attached
> below.
>
>
>
> Thanks!!
>
>
>
> 
>
> ...
>
> public CartPanel(String id) {
>
>      super(id);
>
>      Form panelForm = new Form("panelForm", new
> CompoundPropertyModel(new ShoppingCart())) {
>
>           �...@override
>
>            protected void onSubmit() {
>
>                  // need to rewrite cookie on update
>
>                  ShoppingCart cart = (ShoppingCart) getModelObject();
>
>                  System.out.println(cart.getCartItems());// check if
> cart items got populated
>
>            }
>
>      };
>
>      add(panelForm);
>
>
>
>      IDataProvider dataProvider = new ShoppingCartItemsProvider();
>
>      DataView dataView = new DataView("cartItems", dataProvider) {
>
>           �...@override
>
>            protected void populateItem(final Item item) {
>
>                  final ShoppingCartItem cartItem = (ShoppingCartItem)
> item
>
>                        .getModelObject();
>
>                  item.add(new Label("itemName", cartItem.getName()));
>
>                  item.add(new TextField("quantity", new
> ShoppingCartItemModel(
>
>                        new Model(cartItem),
> ShoppingCartItemType.QUANTITY)));
>
>            }
>
>      };
>
>      // add general text labels and buttons to the cart
>
>      addFieldsAndButtons(panelForm);
>
>      panelForm.add(dataView);
>
> }...
>
> 
>
>
>
> Thanks!!
>
>
>
>
> --
> This e-mail and any attachments may contain confidential material for the 
> sole use of the intended recipient. If you are not the intended recipient, 
> please be aware that any disclosure, copying, distribution or use of this 
> e-mail or any attachment is prohibited. If you have received this e-mail in 
> error, please contact the sender and delete all copies.
> Thank you for your cooperation.
>

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



Re: CompoundPropertyModel and Combobox

2009-05-28 Thread Marco Santos

Thanx for the tip. It work on some cases. I found a pattern. For instance, if
a component (be it a textfield or a DropDownChoice) has it self a Model, for
instance a PropertyModel, the instance variables of the class that is used
on the form model (CompoundPropertyModel) are not filled.


EXAMPLE


the form:


public class ImovelHabitacionalForm extends Form {

private final ImovelHabitacionalInput
imovelHabitacionalInput = new ImovelHabitacionalInput();


...


public ImovelHabitacionalForm() {

super(ID);


setModel(new
CompoundPropertyModel(imovelHabitacionalInput));


buildForm();

}


/*The components creations */


private void buildForm() {

/*TRANSACTION TYPES*/

List transactionTypes =
TipoTransaccaoFacade.getTipoTransaccoes();

transactionType = new
DropDownChoice("transactionType", transactionTypes);


/*DISTRICTS*/

DistritosModel
distritosModel = new DistritosModel();

selectedDistrito = new
SelectedChoice(); /*class with a instance variable "selectedChoice" and
getter and setter*/

distritosDDC = new
DropDownChoice("distritos", new PropertyModel(selectedDistrito,
"selectedChoice"), distritosModel);


/*PRICE*/

priceTextField = new
TextField("price");


/*AREA*/

/*Class with a variable name
area and a getter and a setter*/

private TextFieldAreaModel
areaModel = new TextFieldAreaModel();

areaTextField = new
TextField("area", new PropertyModel(areaModel, "area"));

}

}


/*Part of the user input class used on the form model*/

private class ImovelHabitacionalInput implements IClusterable {

private String district= "";
 
private String transactionType= "";


private String price= "";

private String area = "";


/*GETTERS AND SETTERS*/

}


When the form is submited happens that the transactionType and the price
variables on the class ImovelHabitacionalInput are filled with the values
inserted by the user, but the district and the area dont. the diferences
between the textfields and the dropdownchoices is that the transactionType
and the price doesn't have a model itself. 


Does any one knows why if a model is supllyed to a form model, the
respective instance variables are not filled, even more, those getters and
setters are not called (in debug mode i noticed that too).


Thanks a lot everyone


MARCO SANTOS


Marcin Palka wrote:
> 
> The code below works just fine for me. Instead of using complex type as a
> model object for a drop down I use an instance of IChoiceRenderer to
> control what's used for an id and what's displayed as a value. 
> 
> User user = ;
> setModel(new CompoundPropertyModel(user));
> 
> add(new DropDownChoice("usrRole", SystemRole.asStringList(),
> new IChoiceRenderer() {
> 
> @Override
> public String getDisplayValue(Object object) {
> return Enum.valueOf(SystemRole.class,
> object.toString()).getRoleName();
> }
> 
> @Override
> public String getIdValue(Object object, int index) {
> if (index == -1) {
> return SystemRole.SALESMAN.toString();
> }
> return SystemRole.asStringList().get(index);
> }
> }).setRequired(true));
> 
> The combo items are populated from Enum values:
> 
> public enum SystemRole {
> 
> SYS_ADMIN("Administrator systemu"),
> SERVICEMAN("Serwisant"),
> NETWORK_ADMIN("Administrator sieci"),
> SALESMAN("Pracownik punktu"),
> ANY("Bez roli");
> private final String roleName;
> 
> SystemRole(String roleName) {
> this.roleName = roleName;
> }
> 
> public String getRoleName() {
> return roleName;
> }
> private static List stringList;
> 
> public static List asStringList() {
> if (stringList == null) {
> stringList = new ArrayList();
> for (SystemRole sr : values()) {
> stringList.add(sr.toString());
> }
> }
> return stringList;
> }
> }
> 
> And this is how model object looks like:
> 
> public class User {
> private Integer usrId;
> private String usrLogin;
> private String usrPasswrd;
> private String usrEmail;
> private String usrMobile;
> private String usrLandline;
> private String usrFirstName;
> private String usrLastName;
> private String usrRole;
> }
> 
> Hope this helps :-)
> 
> cheers,
> Marcin
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-and-Combobox-tp23733910p23771469.html
Sent from the Wicket - User mailing list archive at Nabble.com.


Re: CompoundPropertyModel and Combobox

2009-05-27 Thread Marcin Palka

The code below works just fine for me. Instead of using complex type as a
model object for a drop down I use an instance of IChoiceRenderer to control
what's used for an id and what's displayed as a value. 

User user = ;
setModel(new CompoundPropertyModel(user));

add(new DropDownChoice("usrRole", SystemRole.asStringList(), new
IChoiceRenderer() {

@Override
public String getDisplayValue(Object object) {
return Enum.valueOf(SystemRole.class,
object.toString()).getRoleName();
}

@Override
public String getIdValue(Object object, int index) {
if (index == -1) {
return SystemRole.SALESMAN.toString();
}
return SystemRole.asStringList().get(index);
}
}).setRequired(true));

The combo items are populated from Enum values:

public enum SystemRole {

SYS_ADMIN("Administrator systemu"),
SERVICEMAN("Serwisant"),
NETWORK_ADMIN("Administrator sieci"),
SALESMAN("Pracownik punktu"),
ANY("Bez roli");
private final String roleName;

SystemRole(String roleName) {
this.roleName = roleName;
}

public String getRoleName() {
return roleName;
}
private static List stringList;

public static List asStringList() {
if (stringList == null) {
stringList = new ArrayList();
for (SystemRole sr : values()) {
stringList.add(sr.toString());
}
}
return stringList;
}
}

And this is how model object looks like:

public class User {
private Integer usrId;
private String usrLogin;
private String usrPasswrd;
private String usrEmail;
private String usrMobile;
private String usrLandline;
private String usrFirstName;
private String usrLastName;
private String usrRole;
}

Hope this helps :-)

cheers,
Marcin

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-and-Combobox-tp23733910p23741340.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: Compoundpropertymodel with shadow map?

2008-11-21 Thread Nino Saturnino Martinez Vazquez Wael
Ok great.. Seems like SerializationHelper.clone and just a normal 
compound model could work..


Francisco Diaz Trepat - gmail wrote:

Don't know, but LOL.
This might be an instancing issue in which special handling is good for this
scenario but seems to be fine for most cases. And in a lazy TDD programming
way it might be good enough.

Although I know from blog and other threads that you look for greatness :-)
and not just code that works. Which is very inspiring now a days, in this
business hour of programming history.

I'll ask arround though, I think I might know someone who might know, and
also is not my mother...

f(t)

On Thu, Nov 20, 2008 at 6:26 PM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

  

I love simple and simple is good. But this approach has issues with
hibernate if your hibernate sessions are per request and your shadowmodel
lives in multiple requests and your entities has references to other
entities for example 1..* etc ...  In "simple" use cases, and possibly also
when not using hibernate this might be fine. This is what I am exploring
currently. When not attending seminars or talking with people..

Im wondering how eclipselink & openJPA handles the "hibernate lazy load
problem", according to a oracle guy theres not a problem when using Toplink
(which now are eclipselink?)

Input on these things are very welcome...

regards Nino


Francisco Diaz Trepat - gmail wrote:



why?
simple is good. doesn't need to be complex.

what part you dislike the most?

f(t)

On Thu, Nov 20, 2008 at 2:29 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:



  

BTW this is a flawed approch.. We need something a little more
intelligent.. I'll return on the subject..


Nino Saturnino Martinez Vazquez Wael wrote:





heres the raw and completely untested version of it. probably with a
whole
bunch of issues...:

 package zeuzgroup.web.model;
   import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
   import org.apache.wicket.Component;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.model.AbstractPropertyModel;
 import org.apache.wicket.model.CompoundPropertyModel;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.IWrapModel;
   public class EditorModel extends CompoundPropertyModel {
   private final Map newValues = new HashMap();
   public EditorModel(IModel underlyingModel) {
 super(underlyingModel);
 }
   public void fillOriginal() {
   Class c = this.getObject().getClass();
   for (Entry entry : newValues.entrySet()) {
 try {
 Field t = c.getDeclaredField(entry.getKey());
 t.set(this.getObject(), entry.getValue());
 } catch (Exception e) {
 throw new WicketRuntimeException("Could not set "
 + entry.getKey(), e);
 }
   }
 }
   public  IWrapModel wrapOnInheritance(Component component) {
 return new AttachedCompoundPropertyModel(component,
newValues);
 }
   private class AttachedCompoundPropertyModel extends
 AbstractPropertyModel implements IWrapModel {
 private static final long serialVersionUID = 1L;
   private final Component owner;
   private final Map newValues;
   /**
  * Constructor
  *
  * @param owner
  *component that this model has been attached to
  */
 public AttachedCompoundPropertyModel(Component owner,
Map map) {
 super(EditorModel.this);
 this.owner = owner;
 this.newValues = map;
 }
   @Override
 public C getObject() {
 if (EditorModel.this.newValues.containsKey(owner.getId()))
{
 return (C) newValues.get(owner.getId());
 } else {
 return super.getObject();
 }
 }
   @Override
 public void setObject(C object) {
 newValues.put(owner.getId(), object);
 }
   /**
  * @see
org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
  */
 @Override
 protected String propertyExpression() {
 return EditorModel.this.propertyExpression(owner);
 }
   /**
  * @see org.apache.wicket.model.IWrapModel#getWrappedModel()
  */
 public IModel getWrappedModel() {
 return EditorModel.this;
 }
   /**
  * @see org.apache.wicket.model.AbstractPropertyModel#detach()
  */
 @Override
 public void detach() {
 super.detach();
 EditorModel.this.detach();
 }
 }
   }
   // IComponentAssignedModel / IWrapModel

Francisco Diaz Trepat - gmail wrote:



  

Nice, I was up to something similar.

On Tue, Nov 18, 2008

Re: Compoundpropertymodel with shadow map?

2008-11-21 Thread Nino Saturnino Martinez Vazquez Wael

True, this is also what I am thinking about doing...

Johan Compagner wrote:

If you dont want to use an original object why not just clone/create a
copy of the original end use that and then copy the values over again?
(i think beanutils or something van do that for you)

On 11/18/08, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
  

Hi

Im trying todo a compoundpropertymodel which does not change original
values in the "original" model. I need this since I am updating some
stuff in a wizard but I first want to commit when the user confirms in
the end of the wizard, and if the model are changed directly the
transaction are automatically committed to the database

So my idea were to todo a shadowCompoundPropertyModel something like this:

class EditorModel extends CompoundPropertyModel {


private Map newValues=new HashMap();

public EditorModel(CompoundPropertyModel underlyingModel,
String propertyName) {
super(underlyingModel);
}

public getObject (String property){
check if there are something in the map if so return it, otherwise fall
back to the underlying model

}
public setObject (String prop, Value){
put changes in the map...
}

public UpdateOriginal(){
 iterate over the map and use reflection to set values on the original
model..

}

}

Does anybody have something similar floating around, in a more complete
state..? Or could it be done in a easier way?

--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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





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

  


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Re: Compoundpropertymodel with shadow map?

2008-11-21 Thread Johan Compagner
If you dont want to use an original object why not just clone/create a
copy of the original end use that and then copy the values over again?
(i think beanutils or something van do that for you)

On 11/18/08, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
> Hi
>
> Im trying todo a compoundpropertymodel which does not change original
> values in the "original" model. I need this since I am updating some
> stuff in a wizard but I first want to commit when the user confirms in
> the end of the wizard, and if the model are changed directly the
> transaction are automatically committed to the database
>
> So my idea were to todo a shadowCompoundPropertyModel something like this:
>
> class EditorModel extends CompoundPropertyModel {
>
>
> private Map newValues=new HashMap();
>
> public EditorModel(CompoundPropertyModel underlyingModel,
> String propertyName) {
> super(underlyingModel);
> }
>
> public getObject (String property){
> check if there are something in the map if so return it, otherwise fall
> back to the underlying model
>
> }
> public setObject (String prop, Value){
> put changes in the map...
> }
>
> public UpdateOriginal(){
>  iterate over the map and use reflection to set values on the original
> model..
>
> }
>
> }
>
> Does anybody have something similar floating around, in a more complete
> state..? Or could it be done in a easier way?
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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



Re: Compoundpropertymodel with shadow map?

2008-11-20 Thread Francisco Diaz Trepat - gmail
Don't know, but LOL.
This might be an instancing issue in which special handling is good for this
scenario but seems to be fine for most cases. And in a lazy TDD programming
way it might be good enough.

Although I know from blog and other threads that you look for greatness :-)
and not just code that works. Which is very inspiring now a days, in this
business hour of programming history.

I'll ask arround though, I think I might know someone who might know, and
also is not my mother...

f(t)

On Thu, Nov 20, 2008 at 6:26 PM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

> I love simple and simple is good. But this approach has issues with
> hibernate if your hibernate sessions are per request and your shadowmodel
> lives in multiple requests and your entities has references to other
> entities for example 1..* etc ...  In "simple" use cases, and possibly also
> when not using hibernate this might be fine. This is what I am exploring
> currently. When not attending seminars or talking with people..
>
> Im wondering how eclipselink & openJPA handles the "hibernate lazy load
> problem", according to a oracle guy theres not a problem when using Toplink
> (which now are eclipselink?)
>
> Input on these things are very welcome...
>
> regards Nino
>
>
> Francisco Diaz Trepat - gmail wrote:
>
>> why?
>> simple is good. doesn't need to be complex.
>>
>> what part you dislike the most?
>>
>> f(t)
>>
>> On Thu, Nov 20, 2008 at 2:29 AM, Nino Saturnino Martinez Vazquez Wael <
>> [EMAIL PROTECTED]> wrote:
>>
>>
>>
>>> BTW this is a flawed approch.. We need something a little more
>>> intelligent.. I'll return on the subject..
>>>
>>>
>>> Nino Saturnino Martinez Vazquez Wael wrote:
>>>
>>>
>>>
 heres the raw and completely untested version of it. probably with a
 whole
 bunch of issues...:

  package zeuzgroup.web.model;
import java.lang.reflect.Field;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Map.Entry;
import org.apache.wicket.Component;
  import org.apache.wicket.WicketRuntimeException;
  import org.apache.wicket.model.AbstractPropertyModel;
  import org.apache.wicket.model.CompoundPropertyModel;
  import org.apache.wicket.model.IModel;
  import org.apache.wicket.model.IWrapModel;
public class EditorModel extends CompoundPropertyModel {
private final Map newValues = new HashMap>>> Object>();
public EditorModel(IModel underlyingModel) {
  super(underlyingModel);
  }
public void fillOriginal() {
Class c = this.getObject().getClass();
for (Entry entry : newValues.entrySet()) {
  try {
  Field t = c.getDeclaredField(entry.getKey());
  t.set(this.getObject(), entry.getValue());
  } catch (Exception e) {
  throw new WicketRuntimeException("Could not set "
  + entry.getKey(), e);
  }
}
  }
public  IWrapModel wrapOnInheritance(Component component) {
  return new AttachedCompoundPropertyModel(component,
 newValues);
  }
private class AttachedCompoundPropertyModel extends
  AbstractPropertyModel implements IWrapModel {
  private static final long serialVersionUID = 1L;
private final Component owner;
private final Map newValues;
/**
   * Constructor
   *
   * @param owner
   *component that this model has been attached to
   */
  public AttachedCompoundPropertyModel(Component owner,
 Map map) {
  super(EditorModel.this);
  this.owner = owner;
  this.newValues = map;
  }
@Override
  public C getObject() {
  if (EditorModel.this.newValues.containsKey(owner.getId()))
 {
  return (C) newValues.get(owner.getId());
  } else {
  return super.getObject();
  }
  }
@Override
  public void setObject(C object) {
  newValues.put(owner.getId(), object);
  }
/**
   * @see
 org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
   */
  @Override
  protected String propertyExpression() {
  return EditorModel.this.propertyExpression(owner);
  }
/**
   * @see org.apache.wicket.model.IWrapModel#getWrappedModel()
   */
  public IModel getWrappedModel() {
  return EditorModel.this;
  }
/**
   * @see org.apache.wicket.mod

Re: Compoundpropertymodel with shadow map?

2008-11-20 Thread Nino Saturnino Martinez Vazquez Wael
I love simple and simple is good. But this approach has issues with 
hibernate if your hibernate sessions are per request and your 
shadowmodel lives in multiple requests and your entities has references 
to other entities for example 1..* etc ...  In "simple" use cases, and 
possibly also when not using hibernate this might be fine. This is what 
I am exploring currently. When not attending seminars or talking with 
people..


Im wondering how eclipselink & openJPA handles the "hibernate lazy load 
problem", according to a oracle guy theres not a problem when using 
Toplink (which now are eclipselink?)


Input on these things are very welcome...

regards Nino

Francisco Diaz Trepat - gmail wrote:

why?
simple is good. doesn't need to be complex.

what part you dislike the most?

f(t)

On Thu, Nov 20, 2008 at 2:29 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

  

BTW this is a flawed approch.. We need something a little more
intelligent.. I'll return on the subject..


Nino Saturnino Martinez Vazquez Wael wrote:



heres the raw and completely untested version of it. probably with a whole
bunch of issues...:

  package zeuzgroup.web.model;
import java.lang.reflect.Field;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Map.Entry;
import org.apache.wicket.Component;
  import org.apache.wicket.WicketRuntimeException;
  import org.apache.wicket.model.AbstractPropertyModel;
  import org.apache.wicket.model.CompoundPropertyModel;
  import org.apache.wicket.model.IModel;
  import org.apache.wicket.model.IWrapModel;
public class EditorModel extends CompoundPropertyModel {
private final Map newValues = new HashMap();
public EditorModel(IModel underlyingModel) {
  super(underlyingModel);
  }
public void fillOriginal() {
Class c = this.getObject().getClass();
for (Entry entry : newValues.entrySet()) {
  try {
  Field t = c.getDeclaredField(entry.getKey());
  t.set(this.getObject(), entry.getValue());
  } catch (Exception e) {
  throw new WicketRuntimeException("Could not set "
  + entry.getKey(), e);
  }
}
  }
public  IWrapModel wrapOnInheritance(Component component) {
  return new AttachedCompoundPropertyModel(component,
newValues);
  }
private class AttachedCompoundPropertyModel extends
  AbstractPropertyModel implements IWrapModel {
  private static final long serialVersionUID = 1L;
private final Component owner;
private final Map newValues;
/**
   * Constructor
   *
   * @param owner
   *component that this model has been attached to
   */
  public AttachedCompoundPropertyModel(Component owner,
Map map) {
  super(EditorModel.this);
  this.owner = owner;
  this.newValues = map;
  }
@Override
  public C getObject() {
  if (EditorModel.this.newValues.containsKey(owner.getId())) {
  return (C) newValues.get(owner.getId());
  } else {
  return super.getObject();
  }
  }
@Override
  public void setObject(C object) {
  newValues.put(owner.getId(), object);
  }
/**
   * @see
org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
   */
  @Override
  protected String propertyExpression() {
  return EditorModel.this.propertyExpression(owner);
  }
/**
   * @see org.apache.wicket.model.IWrapModel#getWrappedModel()
   */
  public IModel getWrappedModel() {
  return EditorModel.this;
  }
/**
   * @see org.apache.wicket.model.AbstractPropertyModel#detach()
   */
  @Override
  public void detach() {
  super.detach();
  EditorModel.this.detach();
  }
  }
}
// IComponentAssignedModel / IWrapModel

Francisco Diaz Trepat - gmail wrote:

  

Nice, I was up to something similar.

On Tue, Nov 18, 2008 at 9:43 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:





Hi

Im trying todo a compoundpropertymodel which does not change original
values in the "original" model. I need this since I am updating some
stuff
in a wizard but I first want to commit when the user confirms in the end
of
the wizard, and if the model are changed directly the transaction are
automatically committed to the database

So my idea were to todo a shadowCompoundPropertyModel something like
this:

class EditorModel extends CompoundPropertyModel {

 private Map newValues=new HashMap();
   public EditorModel(CompoundPropertyModel underlyingModel,
 Str

Re: Compoundpropertymodel with shadow map?

2008-11-20 Thread Francisco Diaz Trepat - gmail
why?
simple is good. doesn't need to be complex.

what part you dislike the most?

f(t)

On Thu, Nov 20, 2008 at 2:29 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

> BTW this is a flawed approch.. We need something a little more
> intelligent.. I'll return on the subject..
>
>
> Nino Saturnino Martinez Vazquez Wael wrote:
>
>> heres the raw and completely untested version of it. probably with a whole
>> bunch of issues...:
>>
>>   package zeuzgroup.web.model;
>> import java.lang.reflect.Field;
>>   import java.util.HashMap;
>>   import java.util.Map;
>>   import java.util.Map.Entry;
>> import org.apache.wicket.Component;
>>   import org.apache.wicket.WicketRuntimeException;
>>   import org.apache.wicket.model.AbstractPropertyModel;
>>   import org.apache.wicket.model.CompoundPropertyModel;
>>   import org.apache.wicket.model.IModel;
>>   import org.apache.wicket.model.IWrapModel;
>> public class EditorModel extends CompoundPropertyModel {
>> private final Map newValues = new HashMap> Object>();
>> public EditorModel(IModel underlyingModel) {
>>   super(underlyingModel);
>>   }
>> public void fillOriginal() {
>> Class c = this.getObject().getClass();
>> for (Entry entry : newValues.entrySet()) {
>>   try {
>>   Field t = c.getDeclaredField(entry.getKey());
>>   t.set(this.getObject(), entry.getValue());
>>   } catch (Exception e) {
>>   throw new WicketRuntimeException("Could not set "
>>   + entry.getKey(), e);
>>   }
>> }
>>   }
>> public  IWrapModel wrapOnInheritance(Component component) {
>>   return new AttachedCompoundPropertyModel(component,
>> newValues);
>>   }
>> private class AttachedCompoundPropertyModel extends
>>   AbstractPropertyModel implements IWrapModel {
>>   private static final long serialVersionUID = 1L;
>> private final Component owner;
>> private final Map newValues;
>> /**
>>* Constructor
>>*
>>* @param owner
>>*component that this model has been attached to
>>*/
>>   public AttachedCompoundPropertyModel(Component owner,
>> Map map) {
>>   super(EditorModel.this);
>>   this.owner = owner;
>>   this.newValues = map;
>>   }
>> @Override
>>   public C getObject() {
>>   if (EditorModel.this.newValues.containsKey(owner.getId())) {
>>   return (C) newValues.get(owner.getId());
>>   } else {
>>   return super.getObject();
>>   }
>>   }
>> @Override
>>   public void setObject(C object) {
>>   newValues.put(owner.getId(), object);
>>   }
>> /**
>>* @see
>> org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
>>*/
>>   @Override
>>   protected String propertyExpression() {
>>   return EditorModel.this.propertyExpression(owner);
>>   }
>> /**
>>* @see org.apache.wicket.model.IWrapModel#getWrappedModel()
>>*/
>>   public IModel getWrappedModel() {
>>   return EditorModel.this;
>>   }
>> /**
>>* @see org.apache.wicket.model.AbstractPropertyModel#detach()
>>*/
>>   @Override
>>   public void detach() {
>>   super.detach();
>>   EditorModel.this.detach();
>>   }
>>   }
>> }
>> // IComponentAssignedModel / IWrapModel
>>
>> Francisco Diaz Trepat - gmail wrote:
>>
>>> Nice, I was up to something similar.
>>>
>>> On Tue, Nov 18, 2008 at 9:43 AM, Nino Saturnino Martinez Vazquez Wael <
>>> [EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
 Hi

 Im trying todo a compoundpropertymodel which does not change original
 values in the "original" model. I need this since I am updating some
 stuff
 in a wizard but I first want to commit when the user confirms in the end
 of
 the wizard, and if the model are changed directly the transaction are
 automatically committed to the database

 So my idea were to todo a shadowCompoundPropertyModel something like
 this:

 class EditorModel extends CompoundPropertyModel {

  private Map newValues=new HashMap();
public EditorModel(CompoundPropertyModel underlyingModel,
  String propertyName) {
  super(underlyingModel);
  }
  public getObject (String property){
 check if there are something in the map if so return it, otherwise fall
 back to the underlying model

 }  public setObject (String prop, Value){
  put changes in the map...
 }

 public UpdateOrigin

Re: Compoundpropertymodel with shadow map?

2008-11-19 Thread Nino Saturnino Martinez Vazquez Wael
BTW this is a flawed approch.. We need something a little more 
intelligent.. I'll return on the subject..


Nino Saturnino Martinez Vazquez Wael wrote:
heres the raw and completely untested version of it. probably with a 
whole bunch of issues...:


   package zeuzgroup.web.model;
 import java.lang.reflect.Field;
   import java.util.HashMap;
   import java.util.Map;
   import java.util.Map.Entry;
 import org.apache.wicket.Component;
   import org.apache.wicket.WicketRuntimeException;
   import org.apache.wicket.model.AbstractPropertyModel;
   import org.apache.wicket.model.CompoundPropertyModel;
   import org.apache.wicket.model.IModel;
   import org.apache.wicket.model.IWrapModel;
 public class EditorModel extends CompoundPropertyModel {
 private final Map newValues = new 
HashMap();

 public EditorModel(IModel underlyingModel) {
   super(underlyingModel);
   }
 public void fillOriginal() {
 Class c = this.getObject().getClass();
 for (Entry entry : newValues.entrySet()) {
   try {
   Field t = c.getDeclaredField(entry.getKey());
   t.set(this.getObject(), entry.getValue());
   } catch (Exception e) {
   throw new WicketRuntimeException("Could not set "
   + entry.getKey(), e);
   }
 }
   }
 public  IWrapModel wrapOnInheritance(Component 
component) {
   return new AttachedCompoundPropertyModel(component, 
newValues);

   }
 private class AttachedCompoundPropertyModel extends
   AbstractPropertyModel implements IWrapModel {
   private static final long serialVersionUID = 1L;
 private final Component owner;
 private final Map newValues;
 /**
* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner, 
Map map) {

   super(EditorModel.this);
   this.owner = owner;
   this.newValues = map;
   }
 @Override
   public C getObject() {
   if 
(EditorModel.this.newValues.containsKey(owner.getId())) {

   return (C) newValues.get(owner.getId());
   } else {
   return super.getObject();
   }
   }
 @Override
   public void setObject(C object) {
   newValues.put(owner.getId(), object);
   }
 /**
* @see 
org.apache.wicket.model.AbstractPropertyModel#propertyExpression()

*/
   @Override
   protected String propertyExpression() {
   return EditorModel.this.propertyExpression(owner);
   }
 /**
* @see org.apache.wicket.model.IWrapModel#getWrappedModel()
*/
   public IModel getWrappedModel() {
   return EditorModel.this;
   }
 /**
* @see org.apache.wicket.model.AbstractPropertyModel#detach()
*/
   @Override
   public void detach() {
   super.detach();
   EditorModel.this.detach();
   }
   }
 }
 // IComponentAssignedModel / IWrapModel

Francisco Diaz Trepat - gmail wrote:

Nice, I was up to something similar.

On Tue, Nov 18, 2008 at 9:43 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

 

Hi

Im trying todo a compoundpropertymodel which does not change original
values in the "original" model. I need this since I am updating some 
stuff
in a wizard but I first want to commit when the user confirms in the 
end of

the wizard, and if the model are changed directly the transaction are
automatically committed to the database

So my idea were to todo a shadowCompoundPropertyModel something like 
this:


class EditorModel extends CompoundPropertyModel {

  private Map newValues=new HashMap();
public EditorModel(CompoundPropertyModel underlyingModel,
  String propertyName) {
  super(underlyingModel);
  }
 public getObject (String property){
check if there are something in the map if so return it, otherwise fall
back to the underlying model

}  public setObject (String prop, Value){
  put changes in the map...
}

public UpdateOriginal(){
iterate over the map and use reflection to set values on the original
model..

}

}

Does anybody have something similar floating around, in a more complete
state..? Or could it be done in a easier way?

--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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





  




--
-Wicket for love

Nino Martinez Wael

Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread Francisco Diaz Trepat - gmail
[+] on proposition shadow

On Tue, Nov 18, 2008 at 4:16 PM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

> And heres the result in all its glory, should I create jira issue and
> attach the code?.. :
>
> package zeuzgroup.web.model;
>
> import java.lang.reflect.Field;
> import java.lang.reflect.Method;
> import java.util.HashMap;
> import java.util.Map;
> import java.util.Map.Entry;
>
> import org.apache.wicket.Application;
> import org.apache.wicket.Component;
> import org.apache.wicket.Session;
> import org.apache.wicket.WicketRuntimeException;
> import org.apache.wicket.model.AbstractPropertyModel;
> import org.apache.wicket.model.CompoundPropertyModel;
> import org.apache.wicket.model.IModel;
> import org.apache.wicket.model.IWrapModel;
> import org.apache.wicket.util.lang.PropertyResolver;
> import org.apache.wicket.util.lang.PropertyResolverConverter;
>
> public class ShadowCompoundPropertyModel extends
> CompoundPropertyModel {
>
>   private final Map newValues = new HashMap Object>();
>
>   public ShadowCompoundPropertyModel(IModel underlyingModel) {
>   super(underlyingModel);
>   }
>
>   public void fillOriginal() {
>   for (Entry entry : newValues.entrySet()) {
>
>   PropertyResolverConverter prc = null;
>   prc = new
> PropertyResolverConverter(Application.get().getConverterLocator(),
>   Session.get().getLocale());
>   PropertyResolver.setValue(entry.getKey(), getObject(),
> entry.getValue(), prc);
>   }
>   }
>
>   public  IWrapModel wrapOnInheritance(Component component) {
>   return new AttachedCompoundPropertyModel(component, newValues);
>   }
>
>   private class AttachedCompoundPropertyModel extends
>   AbstractPropertyModel implements IWrapModel {
>   private static final long serialVersionUID = 1L;
>
>   private final Component owner;
>
>   private final Map newValues;
>
>   /**
>* Constructor
>*
>* @param owner
>*component that this model has been attached to
>*/
>   public AttachedCompoundPropertyModel(Component owner,
>   Map map) {
>   super(ShadowCompoundPropertyModel.this);
>   this.owner = owner;
>   this.newValues = map;
>   }
>
>   @Override
>   public C getObject() {
>   if
> (ShadowCompoundPropertyModel.this.newValues.containsKey(owner.getId())) {
>   return (C) newValues.get(owner.getId());
>   } else {
>   return super.getObject();
>   }
>   }
>
>   @Override
>   public void setObject(C object) {
>   newValues.put(owner.getId(), object);
>   }
>
>   /**
>* @see
> org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
>*/
>   @Override
>   protected String propertyExpression() {
>   return
> ShadowCompoundPropertyModel.this.propertyExpression(owner);
>   }
>
>   /**
>* @see org.apache.wicket.model.IWrapModel#getWrappedModel()
>*/
>   public IModel getWrappedModel() {
>   return ShadowCompoundPropertyModel.this;
>   }
>
>   /**
>* @see org.apache.wicket.model.AbstractPropertyModel#detach()
>*/
>   @Override
>   public void detach() {
>   super.detach();
>   ShadowCompoundPropertyModel.this.detach();
>   }
>   }
>
> }
>
> // IComponentAssignedModel / IWrapModel
>
>
> Nino Saturnino Martinez Vazquez Wael wrote:
>
>> Hi
>>
>> Im trying todo a compoundpropertymodel which does not change original
>> values in the "original" model. I need this since I am updating some stuff
>> in a wizard but I first want to commit when the user confirms in the end of
>> the wizard, and if the model are changed directly the transaction are
>> automatically committed to the database
>>
>> So my idea were to todo a shadowCompoundPropertyModel something like this:
>>
>> class EditorModel extends CompoundPropertyModel {
>> private Map newValues=new HashMap();
>> public EditorModel(CompoundPropertyModel underlyingModel,
>>   String propertyName) {
>>   super(underlyingModel);
>>   }
>>  public getObject (String property){
>> check if there are something in the map if so return it, otherwise fall
>> back to the underlying model
>>
>> }  public setObject (String prop, Value){
>>   put changes in the map...
>> }
>>
>> public UpdateOriginal(){
>> iterate over the map and use reflection to set values on the original
>> model..
>>
>> }
>>
>> }
>>
>> Does anybody have something similar floating around, in a more complete
>> state..? Or could it be done in a easier way?
>>
>>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread Nino Saturnino Martinez Vazquez Wael
And heres the result in all its glory, should I create jira issue and 
attach the code?.. :


package zeuzgroup.web.model;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.wicket.Application;
import org.apache.wicket.Component;
import org.apache.wicket.Session;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.model.AbstractPropertyModel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IWrapModel;
import org.apache.wicket.util.lang.PropertyResolver;
import org.apache.wicket.util.lang.PropertyResolverConverter;

public class ShadowCompoundPropertyModel extends 
CompoundPropertyModel {


   private final Map newValues = new HashMapObject>();


   public ShadowCompoundPropertyModel(IModel underlyingModel) {
   super(underlyingModel);
   }

   public void fillOriginal() {
   for (Entry entry : newValues.entrySet()) {

   PropertyResolverConverter prc = null;
   prc = new 
PropertyResolverConverter(Application.get().getConverterLocator(),

   Session.get().getLocale());
   PropertyResolver.setValue(entry.getKey(), getObject(), 
entry.getValue(), prc);

   }
   }

   public  IWrapModel wrapOnInheritance(Component component) {
   return new AttachedCompoundPropertyModel(component, newValues);
   }

   private class AttachedCompoundPropertyModel extends
   AbstractPropertyModel implements IWrapModel {
   private static final long serialVersionUID = 1L;

   private final Component owner;

   private final Map newValues;

   /**
* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner,
   Map map) {
   super(ShadowCompoundPropertyModel.this);
   this.owner = owner;
   this.newValues = map;
   }

   @Override
   public C getObject() {
   if 
(ShadowCompoundPropertyModel.this.newValues.containsKey(owner.getId())) {

   return (C) newValues.get(owner.getId());
   } else {
   return super.getObject();
   }
   }

   @Override
   public void setObject(C object) {
   newValues.put(owner.getId(), object);
   }

   /**
* @see 
org.apache.wicket.model.AbstractPropertyModel#propertyExpression()

*/
   @Override
   protected String propertyExpression() {
   return 
ShadowCompoundPropertyModel.this.propertyExpression(owner);

   }

   /**
* @see org.apache.wicket.model.IWrapModel#getWrappedModel()
*/
   public IModel getWrappedModel() {
   return ShadowCompoundPropertyModel.this;
   }

   /**
* @see org.apache.wicket.model.AbstractPropertyModel#detach()
*/
   @Override
   public void detach() {
   super.detach();
   ShadowCompoundPropertyModel.this.detach();
   }
   }

}

// IComponentAssignedModel / IWrapModel

Nino Saturnino Martinez Vazquez Wael wrote:

Hi

Im trying todo a compoundpropertymodel which does not change original 
values in the "original" model. I need this since I am updating some 
stuff in a wizard but I first want to commit when the user confirms in 
the end of the wizard, and if the model are changed directly the 
transaction are automatically committed to the database


So my idea were to todo a shadowCompoundPropertyModel something like 
this:


class EditorModel extends CompoundPropertyModel {
 
   private Map newValues=new HashMap();

 public EditorModel(CompoundPropertyModel underlyingModel,
   String propertyName) {
   super(underlyingModel);
   }
  public getObject (String property){
check if there are something in the map if so return it, otherwise 
fall back to the underlying model


}  public setObject (String prop, Value){
   put changes in the map...
}

public UpdateOriginal(){
iterate over the map and use reflection to set values on the original 
model..


}

}

Does anybody have something similar floating around, in a more 
complete state..? Or could it be done in a easier way?




--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread Francisco Diaz Trepat - gmail
Shadows sounds good... :-)f(t)

On Tue, Nov 18, 2008 at 11:37 AM, James Carman
<[EMAIL PROTECTED]>wrote:

> You could adapt the proxy model thing (I kind of like the name
> "shadow" and I might change mine) to do what you want.  You'd need to
> keep a flag that tells whether or not you've retrieved the value from
> the "destination" model.
>
> On Tue, Nov 18, 2008 at 9:33 AM, Nino Saturnino Martinez Vazquez Wael
> <[EMAIL PROTECTED]> wrote:
> > I do.. But if I use it with a detachable model the idea goes a bit away..
> > Plus I'd like it to be a bit more transparent... Could be me that just
> not
> > know enough
> >
> > James Carman wrote:
> >>
> >> You didn't like the ProxyModelManager?
> >>
> >>
> >>
> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/wicketopia/src/main/java/org/wicketopia/model/proxy/ProxyModelManager.java
> >>
> >>
> >>
> >> On Tue, Nov 18, 2008 at 7:43 AM, Nino Saturnino Martinez Vazquez Wael
> >> <[EMAIL PROTECTED]> wrote:
> >>
> >>>
> >>> Hi
> >>>
> >>> Im trying todo a compoundpropertymodel which does not change original
> >>> values
> >>> in the "original" model. I need this since I am updating some stuff in
> a
> >>> wizard but I first want to commit when the user confirms in the end of
> >>> the
> >>> wizard, and if the model are changed directly the transaction are
> >>> automatically committed to the database
> >>>
> >>> So my idea were to todo a shadowCompoundPropertyModel something like
> >>> this:
> >>>
> >>> class EditorModel extends CompoundPropertyModel {
> >>>
> >>>  private Map newValues=new HashMap();
> >>>public EditorModel(CompoundPropertyModel underlyingModel,
> >>>  String propertyName) {
> >>>  super(underlyingModel);
> >>>  }
> >>>  public getObject (String property){
> >>> check if there are something in the map if so return it, otherwise fall
> >>> back
> >>> to the underlying model
> >>>
> >>> }  public setObject (String prop, Value){
> >>>  put changes in the map...
> >>> }
> >>>
> >>> public UpdateOriginal(){
> >>> iterate over the map and use reflection to set values on the original
> >>> model..
> >>>
> >>> }
> >>>
> >>> }
> >>>
> >>> Does anybody have something similar floating around, in a more complete
> >>> state..? Or could it be done in a easier way?
> >>>
> >>> --
> >>> -Wicket for love
> >>>
> >>> Nino Martinez Wael
> >>> Java Specialist @ Jayway DK
> >>> http://www.jayway.dk
> >>> +45 2936 7684
> >>>
> >>>
> >>> -
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>
> >> -
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> > --
> > -Wicket for love
> >
> > Nino Martinez Wael
> > Java Specialist @ Jayway DK
> > http://www.jayway.dk
> > +45 2936 7684
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread James Carman
You could adapt the proxy model thing (I kind of like the name
"shadow" and I might change mine) to do what you want.  You'd need to
keep a flag that tells whether or not you've retrieved the value from
the "destination" model.

On Tue, Nov 18, 2008 at 9:33 AM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
> I do.. But if I use it with a detachable model the idea goes a bit away..
> Plus I'd like it to be a bit more transparent... Could be me that just not
> know enough
>
> James Carman wrote:
>>
>> You didn't like the ProxyModelManager?
>>
>>
>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/wicketopia/src/main/java/org/wicketopia/model/proxy/ProxyModelManager.java
>>
>>
>>
>> On Tue, Nov 18, 2008 at 7:43 AM, Nino Saturnino Martinez Vazquez Wael
>> <[EMAIL PROTECTED]> wrote:
>>
>>>
>>> Hi
>>>
>>> Im trying todo a compoundpropertymodel which does not change original
>>> values
>>> in the "original" model. I need this since I am updating some stuff in a
>>> wizard but I first want to commit when the user confirms in the end of
>>> the
>>> wizard, and if the model are changed directly the transaction are
>>> automatically committed to the database
>>>
>>> So my idea were to todo a shadowCompoundPropertyModel something like
>>> this:
>>>
>>> class EditorModel extends CompoundPropertyModel {
>>>
>>>  private Map newValues=new HashMap();
>>>public EditorModel(CompoundPropertyModel underlyingModel,
>>>  String propertyName) {
>>>  super(underlyingModel);
>>>  }
>>>  public getObject (String property){
>>> check if there are something in the map if so return it, otherwise fall
>>> back
>>> to the underlying model
>>>
>>> }  public setObject (String prop, Value){
>>>  put changes in the map...
>>> }
>>>
>>> public UpdateOriginal(){
>>> iterate over the map and use reflection to set values on the original
>>> model..
>>>
>>> }
>>>
>>> }
>>>
>>> Does anybody have something similar floating around, in a more complete
>>> state..? Or could it be done in a easier way?
>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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



Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread Nino Saturnino Martinez Vazquez Wael
heres the raw and completely untested version of it. probably with a 
whole bunch of issues...:


   package zeuzgroup.web.model;
  
   import java.lang.reflect.Field;

   import java.util.HashMap;
   import java.util.Map;
   import java.util.Map.Entry;
  
   import org.apache.wicket.Component;

   import org.apache.wicket.WicketRuntimeException;
   import org.apache.wicket.model.AbstractPropertyModel;
   import org.apache.wicket.model.CompoundPropertyModel;
   import org.apache.wicket.model.IModel;
   import org.apache.wicket.model.IWrapModel;
  
   public class EditorModel extends CompoundPropertyModel {
  
   private final Map newValues = new 
HashMap();
  
   public EditorModel(IModel underlyingModel) {

   super(underlyingModel);
   }
  
   public void fillOriginal() {
  
   Class c = this.getObject().getClass();
  
   for (Entry entry : newValues.entrySet()) {

   try {
   Field t = c.getDeclaredField(entry.getKey());
   t.set(this.getObject(), entry.getValue());
   } catch (Exception e) {
   throw new WicketRuntimeException("Could not set "
   + entry.getKey(), e);
   }
  
   }

   }
  
   public  IWrapModel wrapOnInheritance(Component component) {
   return new AttachedCompoundPropertyModel(component, 
newValues);

   }
  
   private class AttachedCompoundPropertyModel extends

   AbstractPropertyModel implements IWrapModel {
   private static final long serialVersionUID = 1L;
  
   private final Component owner;
  
   private final Map newValues;
  
   /**

* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner, 
Map map) {

   super(EditorModel.this);
   this.owner = owner;
   this.newValues = map;
   }
  
   @Override

   public C getObject() {
   if (EditorModel.this.newValues.containsKey(owner.getId())) {
   return (C) newValues.get(owner.getId());
   } else {
   return super.getObject();
   }
   }
  
   @Override

   public void setObject(C object) {
   newValues.put(owner.getId(), object);
   }
  
   /**
* @see 
org.apache.wicket.model.AbstractPropertyModel#propertyExpression()

*/
   @Override
   protected String propertyExpression() {
   return EditorModel.this.propertyExpression(owner);
   }
  
   /**

* @see org.apache.wicket.model.IWrapModel#getWrappedModel()
*/
   public IModel getWrappedModel() {
   return EditorModel.this;
   }
  
   /**

* @see org.apache.wicket.model.AbstractPropertyModel#detach()
*/
   @Override
   public void detach() {
   super.detach();
   EditorModel.this.detach();
   }
   }
  
   }
  
   // IComponentAssignedModel / IWrapModel


Francisco Diaz Trepat - gmail wrote:

Nice, I was up to something similar.

On Tue, Nov 18, 2008 at 9:43 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

  

Hi

Im trying todo a compoundpropertymodel which does not change original
values in the "original" model. I need this since I am updating some stuff
in a wizard but I first want to commit when the user confirms in the end of
the wizard, and if the model are changed directly the transaction are
automatically committed to the database

So my idea were to todo a shadowCompoundPropertyModel something like this:

class EditorModel extends CompoundPropertyModel {

  private Map newValues=new HashMap();
public EditorModel(CompoundPropertyModel underlyingModel,
  String propertyName) {
  super(underlyingModel);
  }
 public getObject (String property){
check if there are something in the map if so return it, otherwise fall
back to the underlying model

}  public setObject (String prop, Value){
  put changes in the map...
}

public UpdateOriginal(){
iterate over the map and use reflection to set values on the original
model..

}

}

Does anybody have something similar floating around, in a more complete
state..? Or could it be done in a easier way?

--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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





  


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


-

Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread Nino Saturnino Martinez Vazquez Wael
I do.. But if I use it with a detachable model the idea goes a bit 
away.. Plus I'd like it to be a bit more transparent... Could be me that 
just not know enough


James Carman wrote:

You didn't like the ProxyModelManager?

https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/wicketopia/src/main/java/org/wicketopia/model/proxy/ProxyModelManager.java



On Tue, Nov 18, 2008 at 7:43 AM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
  

Hi

Im trying todo a compoundpropertymodel which does not change original values
in the "original" model. I need this since I am updating some stuff in a
wizard but I first want to commit when the user confirms in the end of the
wizard, and if the model are changed directly the transaction are
automatically committed to the database

So my idea were to todo a shadowCompoundPropertyModel something like this:

class EditorModel extends CompoundPropertyModel {

  private Map newValues=new HashMap();
public EditorModel(CompoundPropertyModel underlyingModel,
  String propertyName) {
  super(underlyingModel);
  }
 public getObject (String property){
check if there are something in the map if so return it, otherwise fall back
to the underlying model

}  public setObject (String prop, Value){
  put changes in the map...
}

public UpdateOriginal(){
iterate over the map and use reflection to set values on the original
model..

}

}

Does anybody have something similar floating around, in a more complete
state..? Or could it be done in a easier way?

--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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





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

  


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread James Carman
You didn't like the ProxyModelManager?

https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/wicketopia/src/main/java/org/wicketopia/model/proxy/ProxyModelManager.java



On Tue, Nov 18, 2008 at 7:43 AM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
> Hi
>
> Im trying todo a compoundpropertymodel which does not change original values
> in the "original" model. I need this since I am updating some stuff in a
> wizard but I first want to commit when the user confirms in the end of the
> wizard, and if the model are changed directly the transaction are
> automatically committed to the database
>
> So my idea were to todo a shadowCompoundPropertyModel something like this:
>
> class EditorModel extends CompoundPropertyModel {
>
>   private Map newValues=new HashMap();
> public EditorModel(CompoundPropertyModel underlyingModel,
>   String propertyName) {
>   super(underlyingModel);
>   }
>  public getObject (String property){
> check if there are something in the map if so return it, otherwise fall back
> to the underlying model
>
> }  public setObject (String prop, Value){
>   put changes in the map...
> }
>
> public UpdateOriginal(){
> iterate over the map and use reflection to set values on the original
> model..
>
> }
>
> }
>
> Does anybody have something similar floating around, in a more complete
> state..? Or could it be done in a easier way?
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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



Re: Compoundpropertymodel with shadow map?

2008-11-18 Thread Francisco Diaz Trepat - gmail
Nice, I was up to something similar.

On Tue, Nov 18, 2008 at 9:43 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

> Hi
>
> Im trying todo a compoundpropertymodel which does not change original
> values in the "original" model. I need this since I am updating some stuff
> in a wizard but I first want to commit when the user confirms in the end of
> the wizard, and if the model are changed directly the transaction are
> automatically committed to the database
>
> So my idea were to todo a shadowCompoundPropertyModel something like this:
>
> class EditorModel extends CompoundPropertyModel {
>
>   private Map newValues=new HashMap();
> public EditorModel(CompoundPropertyModel underlyingModel,
>   String propertyName) {
>   super(underlyingModel);
>   }
>  public getObject (String property){
> check if there are something in the map if so return it, otherwise fall
> back to the underlying model
>
> }  public setObject (String prop, Value){
>   put changes in the map...
> }
>
> public UpdateOriginal(){
> iterate over the map and use reflection to set values on the original
> model..
>
> }
>
> }
>
> Does anybody have something similar floating around, in a more complete
> state..? Or could it be done in a easier way?
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: CompoundPropertyModel and collection attributes

2008-10-13 Thread Jeremy Thomerson
In that example, the ID in new TextField("") should be new
TextField("number") - sorry

On Mon, Oct 13, 2008 at 8:42 PM, Jeremy Thomerson <[EMAIL PROTECTED]
> wrote:

> Use some sort of repeater over your collection, then add the individual
> form components inside that.
>
> add(new ListView("phones") {
>
> @Override
> protected void populateItem(ListItem item) {
> item.setModel(new CompoundPropertyModel(item.getModel()));
> item.add(new TextField(""));
> }
>
> });
>
>
> 
> 
> 
> 
> 
>
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
> On Mon, Oct 13, 2008 at 6:45 PM, Cristina <[EMAIL PROTECTED]> wrote:
>
>>
>> Hello,
>>
>> I'm working on an application that will have a simple Form in front of a
>> rather complex object graph. I'm using JPA implemented by Hibernate at the
>> persistence layer.
>>
>> In an effort to keep things simple I'm using CompoundPropertyModel in the
>> Form constructor:
>>
>>Person p = session.getCurrentPerson();
>>setModel(new CompoundPropertyModel(p));
>>
>> CompoundPropertyModel allows me to easily define anonymous TextFields to
>> capture the new values of plain and object attributes of Person:
>>
>>add(new TextField("lastName");
>>// ...
>>add(new TextField("address.city");
>>
>> Now suppose Person has an attribute whose type is a collection:
>>
>>private List phones;
>>
>> How can I access all phones in the collection and then generate the
>> corresponding TextFields for the two (or more) Phone attributes?
>>
>> Thanks so much,
>>
>> Cristina
>>
>> --
>> View this message in context:
>> http://www.nabble.com/CompoundPropertyModel-and-collection-attributes-tp19964896p19964896.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com


Re: CompoundPropertyModel and collection attributes

2008-10-13 Thread Jeremy Thomerson
Use some sort of repeater over your collection, then add the individual form
components inside that.

add(new ListView("phones") {

@Override
protected void populateItem(ListItem item) {
item.setModel(new CompoundPropertyModel(item.getModel()));
item.add(new TextField(""));
}

});









-- 
Jeremy Thomerson
http://www.wickettraining.com

On Mon, Oct 13, 2008 at 6:45 PM, Cristina <[EMAIL PROTECTED]> wrote:

>
> Hello,
>
> I'm working on an application that will have a simple Form in front of a
> rather complex object graph. I'm using JPA implemented by Hibernate at the
> persistence layer.
>
> In an effort to keep things simple I'm using CompoundPropertyModel in the
> Form constructor:
>
>Person p = session.getCurrentPerson();
>setModel(new CompoundPropertyModel(p));
>
> CompoundPropertyModel allows me to easily define anonymous TextFields to
> capture the new values of plain and object attributes of Person:
>
>add(new TextField("lastName");
>// ...
>add(new TextField("address.city");
>
> Now suppose Person has an attribute whose type is a collection:
>
>private List phones;
>
> How can I access all phones in the collection and then generate the
> corresponding TextFields for the two (or more) Phone attributes?
>
> Thanks so much,
>
> Cristina
>
> --
> View this message in context:
> http://www.nabble.com/CompoundPropertyModel-and-collection-attributes-tp19964896p19964896.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


RE: CompoundPropertyModel need to track changes

2008-04-14 Thread Karen Schaper
Thanks.  

My class variables for example are _name with the underscore.

and the getter and setter would be setName and getName.

In my form for this page I had included the underscore _name so I think wicket 
was looking for set_Name.  Once I changed the wicket:id to be just name the 
setter setName was called.

Thank you for the clues.



> -Original Message-
> From: Gerolf Seitz [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 14, 2008 7:18 AM
> To: users@wicket.apache.org
> Subject: Re: CompoundPropertyModel need to track changes
> 
> 
> On Mon, Apr 14, 2008 at 1:05 PM, Maurice Marrink 
> <[EMAIL PROTECTED]> wrote:
> 
> > Hmm, it should try to use bean methods before trying the field directly.
> > you could try changing the wicket id of your formcomponent to the full
> > method name, e.g. setLastname() if your property is lastname.
> > If that does not work, it might indicate a problem with your getters
> > and setters.
> >
> 
> it could also be that he only provided a getter or a setter and not both.
> in this case, the field is accessed directly.
> 
>   Gerolf
> 
> 
> >
> > An alternative way to intercept changes (only those coming through the
> > compoundmodel) is to override
> > CompoundPropertyModel#wrapOnInheritance(Component) and return a model
> > similar to AttachedCompoundPropertyModel where you overwrite the
> > setObject method to listen for changes. Unfortunately you cannot
> > extend it because it is private so you have to copy paste it.
> >
> > Maurice
> >
> > On Mon, Apr 14, 2008 at 5:37 AM, Karen Schaper
> > <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > >  I am using a CompoundPropertyModel.
> > >
> > >  CompoundPropertyModel personModel  = new CompoundPropertyModel(
> > >  person );
> > >  Form_editForm= new 
> EditPersonForm(
> > "editForm",
> > >  personModel ) ;
> > >
> > >  Upon submitting the form, I thought that the setter methods would be
> > called
> > >  on the person object. How is the person object updated?  The code in
> > the
> > >  setter methods of person are not called.
> > >
> > >  Am I missing something?
> > >
> > >  I want to track changes in my object and I wanted to check for the
> > change in
> > >  the setter methods of the person object.
> > >
> > >  Thanks for any help.  It is greatly appreciated!
> > >
> > >  Karen
> > >
> > >
> > >
> > >
> > >  -
> > >  To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >  For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 


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



Re: CompoundPropertyModel need to track changes

2008-04-14 Thread Gerolf Seitz
On Mon, Apr 14, 2008 at 1:05 PM, Maurice Marrink <[EMAIL PROTECTED]> wrote:

> Hmm, it should try to use bean methods before trying the field directly.
> you could try changing the wicket id of your formcomponent to the full
> method name, e.g. setLastname() if your property is lastname.
> If that does not work, it might indicate a problem with your getters
> and setters.
>

it could also be that he only provided a getter or a setter and not both.
in this case, the field is accessed directly.

  Gerolf


>
> An alternative way to intercept changes (only those coming through the
> compoundmodel) is to override
> CompoundPropertyModel#wrapOnInheritance(Component) and return a model
> similar to AttachedCompoundPropertyModel where you overwrite the
> setObject method to listen for changes. Unfortunately you cannot
> extend it because it is private so you have to copy paste it.
>
> Maurice
>
> On Mon, Apr 14, 2008 at 5:37 AM, Karen Schaper
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> >  I am using a CompoundPropertyModel.
> >
> >  CompoundPropertyModel personModel  = new CompoundPropertyModel(
> >  person );
> >  Form_editForm= new EditPersonForm(
> "editForm",
> >  personModel ) ;
> >
> >  Upon submitting the form, I thought that the setter methods would be
> called
> >  on the person object. How is the person object updated?  The code in
> the
> >  setter methods of person are not called.
> >
> >  Am I missing something?
> >
> >  I want to track changes in my object and I wanted to check for the
> change in
> >  the setter methods of the person object.
> >
> >  Thanks for any help.  It is greatly appreciated!
> >
> >  Karen
> >
> >
> >
> >
> >  -
> >  To unsubscribe, e-mail: [EMAIL PROTECTED]
> >  For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: CompoundPropertyModel need to track changes

2008-04-14 Thread Maurice Marrink
Hmm, it should try to use bean methods before trying the field directly.
you could try changing the wicket id of your formcomponent to the full
method name, e.g. setLastname() if your property is lastname.
If that does not work, it might indicate a problem with your getters
and setters.

An alternative way to intercept changes (only those coming through the
compoundmodel) is to override
CompoundPropertyModel#wrapOnInheritance(Component) and return a model
similar to AttachedCompoundPropertyModel where you overwrite the
setObject method to listen for changes. Unfortunately you cannot
extend it because it is private so you have to copy paste it.

Maurice

On Mon, Apr 14, 2008 at 5:37 AM, Karen Schaper
<[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I am using a CompoundPropertyModel.
>
>  CompoundPropertyModel personModel  = new CompoundPropertyModel(
>  person );
>  Form_editForm= new EditPersonForm( 
> "editForm",
>  personModel ) ;
>
>  Upon submitting the form, I thought that the setter methods would be called
>  on the person object. How is the person object updated?  The code in the
>  setter methods of person are not called.
>
>  Am I missing something?
>
>  I want to track changes in my object and I wanted to check for the change in
>  the setter methods of the person object.
>
>  Thanks for any help.  It is greatly appreciated!
>
>  Karen
>
>
>
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-08 Thread Fabio Fioretti
On 10/8/07, Kent Tong <[EMAIL PROTECTED]> wrote:
> It's a feature. When the selection changes, the user might have entered
> something into say a text field. Generally we don't want to lose that
> input (because all you want to do may be to show or hide a certain component
> depending on the selection), therefore it is saved and redisplayed to the
> user. By default it is clear only when the form is submitted and validation
> is passed successfully.

Ok, this behavior is understandable and fine. But when, after a failed
validation, the model object of the form is changed (by a new user's
selection on the ListChoice) and the form is refreshed, I'd expect it
to display the newly selected instance instead of the one that failed
validation. I mean, it's ok that the input isn't lost when validation
fails, but this should be limited to the object that actually failed
validation and it should't prevent using the form to manipulate
another instance after having changed form's model object accordingly.
In this sense, the feature looks like a limitation in my particular
case.

Of course I may be missing something, or not using the form as it is
meant to be used...


Thanks a lot,

Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-08 Thread Kent Tong


Fabio Fioretti wrote:
> 
> You were right Kent, thanks a lot! Calling clearInput() in the
> updating behavior really fixes the problem.
> 
> What I miss now is why the CompoundPropertyModel breaks if the form is
> not manually reset by calling clearInput(). Is it a bug or a feature?
> :)
> 

It's a feature. When the selection changes, the user might have entered
something into say a text field. Generally we don't want to lose that
input (because all you want to do may be to show or hide a certain component
depending on the selection), therefore it is saved and redisplayed to the 
user. By default it is clear only when the form is submitted and validation 
is passed successfully.


-
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13092730
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-08 Thread Fabio Fioretti
On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> > *BUT*, when the user edits one of the recommendations making errors,
> > tries to save it and form validation fails, the panel's
> > CompoundPropertyModel seems to detach from the underlying
> > AbstractModel and, if the user selects another choice on the
> > ListChoice, the form is refreshed but it keeps showing data of the
> > recommendation instance that failed validation.
>
> Not sure what this could be. Would you be able to create a test case
> or quickstart project that shows the bug?

Given that calling form.clearInput() inside ListChoice's updating
behavior solves the problem, is it still useful to create a test case
to show CompoundPropertyModel's detachment or is it explainable now?
I'm still missing an explanation, but probably you are not (and in
this case, please share :-).


Thanks a lot,

Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-08 Thread Fabio Fioretti
On 10/6/07, Kent Tong <[EMAIL PROTECTED]> wrote:
> Even though you're not using wantOnSelectionChangedNotifications(),
> what I said applies: you need to call clearInput() like:
[CUT]
> recommendationForm.clearInput(); //THIS LINE IS WHAT YOU NEED

You were right Kent, thanks a lot! Calling clearInput() in the
updating behavior really fixes the problem.

What I miss now is why the CompoundPropertyModel breaks if the form is
not manually reset by calling clearInput(). Is it a bug or a feature?
:)


Thank you for your time and precious help.


Kindest regards,

Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-05 Thread Kent Tong


Fabio Fioretti wrote:
> 
> The ListChoice uses the same AbstractModel on which the panel inside
> the form builds its CompoundPropertyModel (see my previous posts):
> when user's selection changes, the AbstractModel correctly replaces
> its object with the newly selected instance and the form gets
> refreshed by an AjaxFormComponentUpdatingBehavior (attached to
> ListChoice's "onclick" event) to display the new instance (read from
> the same AbstractModel).
> 

Even though you're not using wantOnSelectionChangedNotifications(),
what I said applies: you need to call clearInput() like:

ListChoice lc = new ListChoice("lc", ...);
lc.add(new OnChangeAjaxBehavior() {
protected void onUpdate(AjaxRequestTarget target) {
recommendationForm.clearInput(); //THIS LINE IS WHAT 
YOU NEED
target.addComponent(recommendationPanel);
}
});

--
Kent Tong
Free tutorials on Wicket at http://www.agileskills2.org/EWDW
-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13069882
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-05 Thread Kent Tong


Fabio Fioretti wrote:
> 
> The ListChoice uses the same AbstractModel on which the panel inside
> the form builds its CompoundPropertyModel (see my previous posts):
> when user's selection changes, the AbstractModel correctly replaces
> its object with the newly selected instance and the form gets
> refreshed by an AjaxFormComponentUpdatingBehavior (attached to
> ListChoice's "onclick" event) to display the new instance (read from
> the same AbstractModel).
> 

Even though you're not using wantOnSelectionChangedNotifications(),
what I said applies: you need to call clearInput() like:

ListChoice lc = new ListChoice("lc", ...);
lc.add(new OnChangeAjaxBehavior() {
protected void onUpdate(AjaxRequestTarget target) {
recommendationForm.clearInput(); //THIS LINE IS WHAT 
YOU NEED
target.addComponent(recommendationPanel);
}
});


-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13069881
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-05 Thread Eelco Hillenius
> *BUT*, when the user edits one of the recommendations making errors,
> tries to save it and form validation fails, the panel's
> CompoundPropertyModel seems to detach from the underlying
> AbstractModel and, if the user selects another choice on the
> ListChoice, the form is refreshed but it keeps showing data of the
> recommendation instance that failed validation.

Not sure what this could be. Would you be able to create a test case
or quickstart project that shows the bug?

Eelco

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-05 Thread Fabio Fioretti
On 10/5/07, Kent Tong <[EMAIL PROTECTED]> wrote:

Hello, thanks for your reply.

> I suppose you're using wantOnSelectionChangedNotifications() to trigger
> the refresh?

No, I'm not.

The ListChoice uses the same AbstractModel on which the panel inside
the form builds its CompoundPropertyModel (see my previous posts):
when user's selection changes, the AbstractModel correctly replaces
its object with the newly selected instance and the form gets
refreshed by an AjaxFormComponentUpdatingBehavior (attached to
ListChoice's "onclick" event) to display the new instance (read from
the same AbstractModel).

Everything works really smooth: the user selects a recommendation from
the list, he edits it, saves it, then he clicks on another
recommendation from the list and edits this other one, and so on.

*BUT*, when the user edits one of the recommendations making errors,
tries to save it and form validation fails, the panel's
CompoundPropertyModel seems to detach from the underlying
AbstractModel and, if the user selects another choice on the
ListChoice, the form is refreshed but it keeps showing data of the
recommendation instance that failed validation.

Any suggestion would be really appreciated, because maybe I'm missing
something about the "inner mechanisms" of Wicket.


Thank you all for any help,

Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-05 Thread Kent Tong


Fabio Fioretti wrote:
> 
> This is what I do, basically:
> 1) Select a choice from the ListChoice;
> 2) The form automatically fills with the data of the selected
> recommendation instance;
> 3) Modify the data in the form so that validation will fail;
> 4) Submit data --> validation fails;
> 5) Select another choice from the ListChoice;
> 6) The form doesn't get updated anymore (and keeps showing old data of
> the recommendation instance that failed validation)
> 

I suppose you're using wantOnSelectionChangedNotifications() to trigger
the refresh? In that case it won't refresh any input entered by the user.
Validation plays no role here because such a form refresh does NOT invoke
the validation logic.

In order to refresh the data and erase what the user has entered, call
clearInput() on the form:

ListChoice recommendation = new ListChoice("recommendation", ...) {
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
protected void onSelectionChanged(Object newSelection) {
recommendationForm.clearInput();
}
};

--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13057990
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-04 Thread Fabio Fioretti
P.S.: I'm using Wicket 1.2.6.


Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-04 Thread Fabio Fioretti
On 10/3/07, Martin-2 <[EMAIL PROTECTED]> wrote:
[ CUT on useful suggestions: thanks a lot ]
> The thing is: it's always better to rely on wicket for state handling and
> variable updating. So if two components refer to the same thing, make sure
> your model object is the same for both (or a property of the model object).
> This keeps your data where it belongs (to the model of MVC) and frees you
> from the hassle to deal with update events.

This is what I'm doing indeed: both the ListChoice (which, by the way,
is external to the form) and the panel inside the form are now sharing
the same AbstractModel defined like this:

final IModel recommendationModel = new AbstractModel(){
public Object getObject(Component component) {
return currentRecommendation;
}

public void setObject(Component component, Object object) {
currentRecommendation = (Recommendation) object;
}
};

The ListChoice uses the abstract model directly; the panel uses a
CompoundPropertyModel(recommendationModel) (i.e. over the abstract
one).

What I'm trying to understand is why, when form validation fails, the
CompoundPropertyModel seems to detach from the underlying
AbstractModel and doesn't pass new data to the panel anymore, even if
the AbstractModel correctly keeps getting updated on ListChoice
selection change (I tested it).

This is what I do, basically:

1) Select a choice from the ListChoice;
2) The form automatically fills with the data of the selected
recommendation instance;
3) Modify the data in the form so that validation will fail;
4) Submit data --> validation fails;
5) Select another choice from the ListChoice;
6) The form doesn't get updated anymore (and keeps showing old data of
the recommendation instance that failed validation)

If I come back to choice corresponding to the instance that failed
validation, modify the wrong fields and submit it again, everything
restarts working and the CompoundPropertyModel wakes up again.

> As a last resort, you could put the currentRecommendation to the session,
> the brutal php approach ;)

I'd like to avoid that approach. ;)

> Another thought... The form works until the first time validation failes.
> Check if subsequents submits go through onSubmit().

If I correct inserted data so that validation succeeds, yes,
onSubmit() is executed; otherwise, of course not.


Thanks again for your time and suggestions,

Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-03 Thread anita nichols
How do I use datagrid on wicket?
I tried the datagrid sample on wicket 1.2 is sooo confusing.

Any sugestion where to look


Re: CompoundPropertyModel stops working when form validation fails.

2007-10-03 Thread Martin-2

Ok, now I undestand better. So if the model of your page is complex, just put
the complex data in a custom model object and then use page.setModel(new
Model(complexObject)). Just move the get/set of your variable into the model
object.

In the form on submit then do

getPage().getModel().getObject().setCurrentRecommendation(selectedValue).

And the panel would be 

new CustomPanel("customPanel", new PropertyModel(getPage().getModel(),
"currentRecommendation");

As for refreshing, just replace 

setResponsePage(getPage())

with 

ajaxRequestTarget.addComponent(customPanel);

or whatever you'd like to be updated.

The thing is: it's always better to rely on wicket for state handling and
variable updating. So if two components refer to the same thing, make sure
your model object is the same for both (or a property of the model object).
This keeps your data where it belongs (to the model of MVC) and frees you
from the hassle to deal with update events.

As a last resort, you could put the currentRecommendation to the session,
the brutal php approach ;)

Another thought... The form works until the first time validation failes.
Check if subsequents submits go through onSubmit(). 

bw,
Martin


Fabio Fioretti wrote:
> 
> On 10/3/07, Martin-2 <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
> 
> Hi, thanks for the quick reply.
> 
>> if I understand correctly, the page variable and the panel model should
>> always point to the same thing.
> 
> Right.
> 
>> I suggest you give your page a model with
>> currentRecommendation as model object. Then construct your panel with the
>> same model instance as the page (or wrap it with an IChainingModel) and
>> get
>> rid of the page wide variable.
> 
> I can't do that because my page is rather complex and it deals with at
> least two different kinds of objects. That's why I choose to have the
> currentRecommendation page variable instead, and a panel inside the
> related form that deals with the variable through the
> CompoundPropertyModel.
> 
>> The form's onSubmit() would be like:
>>
>> selectedValue = obtainSelectedValue();
>> getPage().getModel().setObject(selectedValue);
>> setResponsePage(getPage());
>>
>> so setting the page's model object to the choice the user selected, and
>> only
>> setting it if validation succeeds.
> 
> I don't think this could solve my problem because:
> 1) I don't want the whole page to be refreshed or reloaded but only
> the panel that deals with currentRecommendation;
> 2) more important, I don't want the panel to be refreshed only if
> validation succeeds; I want it to always reflect user's selection from
> the ListChoice, i.e. the currentRecommendation which is the model
> object of the panel.
> 
> The problem here is that, when form validation fails, the panel (which
> is contained in the form) stops responding to user's selections on the
> ListChoice as if its model loses the pointer to currentRecommendation.
> 
> I hope I've been clear enough, 'cause it's not so easy to explain...
> 
> 
> Thanks a lot for your help!
> 
> Fabio Fioretti - WindoM
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13023833
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-03 Thread Fabio Fioretti
On 10/3/07, Martin-2 <[EMAIL PROTECTED]> wrote:
>
> Hi,

Hi, thanks for the quick reply.

> if I understand correctly, the page variable and the panel model should
> always point to the same thing.

Right.

> I suggest you give your page a model with
> currentRecommendation as model object. Then construct your panel with the
> same model instance as the page (or wrap it with an IChainingModel) and get
> rid of the page wide variable.

I can't do that because my page is rather complex and it deals with at
least two different kinds of objects. That's why I choose to have the
currentRecommendation page variable instead, and a panel inside the
related form that deals with the variable through the
CompoundPropertyModel.

> The form's onSubmit() would be like:
>
> selectedValue = obtainSelectedValue();
> getPage().getModel().setObject(selectedValue);
> setResponsePage(getPage());
>
> so setting the page's model object to the choice the user selected, and only
> setting it if validation succeeds.

I don't think this could solve my problem because:
1) I don't want the whole page to be refreshed or reloaded but only
the panel that deals with currentRecommendation;
2) more important, I don't want the panel to be refreshed only if
validation succeeds; I want it to always reflect user's selection from
the ListChoice, i.e. the currentRecommendation which is the model
object of the panel.

The problem here is that, when form validation fails, the panel (which
is contained in the form) stops responding to user's selections on the
ListChoice as if its model loses the pointer to currentRecommendation.

I hope I've been clear enough, 'cause it's not so easy to explain...


Thanks a lot for your help!

Fabio Fioretti - WindoM

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



Re: CompoundPropertyModel stops working when form validation fails.

2007-10-03 Thread Martin-2

Hi,

if I understand correctly, the page variable and the panel model should
always point to the same thing. I suggest you give your page a model with
currentRecommendation as model object. Then construct your panel with the
same model instance as the page (or wrap it with an IChainingModel) and get
rid of the page wide variable. The form's onSubmit() would be like:

selectedValue = obtainSelectedValue();
getPage().getModel().setObject(selectedValue);
setResponsePage(getPage());

so setting the page's model object to the choice the user selected, and only
setting it if validation succeeds. This is what we do in a similar case, we
got one listChoice that controls the whole page and so a lot of components.

hope that helps,
Martin


Fabio Fioretti wrote:
> 
> Hi all,
> 
> thanks for your time and for keeping up this precious users' list.
> 
> I have a page with a page-global "currentRecommendation" variable. The
> instance of this variable is updated by selecting one of the entries
> of a ListChoice; basically, the ListChoice deals with a list of
> "recommendations" instances and sets "currentRecommendation" to the
> one selected by the user.
> 
> When a recommendation is selected, its data are loaded and displayed
> in a "recommendationForm" (contained in the same page) defined like
> this:
> 
> recommendationForm = new Form("recommendationForm");
> 
> The form contains a custom recommendationPanel which is linked to the
> "currentRecommendation" instance by a CompoundPropertyModel built on
> an AbstractReadOnlyModel, just like this:
> 
> IModel recommendationModel = new AbstractReadOnlyModel() {
> @Override
> public Object getObject(Component component) {
> return currentRecommendation;
> }
> };
> 
> recommendationPanel = new CustomPanel("recommendationPanel", new
> CompoundPropertyModel(recommendationModel));
> 
> The problem is that when the form is submitted and validation *fails*,
> the CompoundPropertyModel of the "recommendationPanel" seems to
> disconnect from the "currentRecommendation" instance, because clicking
> on a different entry of the ListChoice mentioned above still refreshes
> the form but doesn't update the data contained in it anymore.
> In other words, the underlying "currentRecommendation" instance keeps
> changing correctly on ListChoice selection change (and the
> AbstractReadOnlyModel correctly picks up the selected instance), but
> the form (i.e. the panel contained in it) keeps displaying the
> instance that failed validation and doesn't show the newly selected
> recommendation instance anymore.
> The whole thing happens only when form validation fails.
> 
> What am I missing?
> 
> 
> Thanks a lot for your help,
> 
> Fabio Fioretti - WindoM
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13021884
Sent from the Wicket - User mailing list archive at Nabble.com.


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