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 sori...@gmail.com 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

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 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

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 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 input type=submit 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 delta...@hotmail.com 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 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
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 delta...@hotmail.com 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
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 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 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=ramlastName=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=ramlastName=babu . I have changed
the URL like https:localhost:8080/addcard?firstName=ravilastName=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 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
input type=text id=firstName name=firstName wicket:id=firstName
value= size=20 maxlength=10 /
  input type=text id=lastName name=lastName wicket:id=lastName
value= size=20 maxlength=20 /

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();
CompoundPropertyModelCustomer  compoundPropertyModel = new
CompoundPropertyModelCustomer(customer );
 final Form?  addCardForm= new
FormCreditCard(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=ramlastName=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=ravilastName=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
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 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:

CompoundPropertyModelHomePage  model = new 
CompoundPropertyModelHomePage(this);
FormHomePage  form = new FormHomePage(form, model);
form.add(new TextFieldString(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-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 TextFieldString(street));
}

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

return new CompoundPropertyModelObject(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() {
   FormSomePage form = new FormSomePage(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:
 
  CompoundPropertyModelHomePage  model = new
 CompoundPropertyModelHomePage(this);
  FormHomePage  form = new FormHomePage(form, model);
  form.add(new TextFieldString(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: 

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:

FormHomePage  form = new FormHomePage(form, new 
CompoundPropertyModelHomePage(this)); // HomePage has an instance of Person called person
form.add(new TextFieldString(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 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:
 
  FormHomePage  form = new FormHomePage(form, new
 CompoundPropertyModelHomePage(this)); // HomePage has an instance of Person
 called person
  form.add(new TextFieldString(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
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
 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:

CompoundPropertyModelHomePage model = new 
CompoundPropertyModelHomePage(this);
FormHomePage form = new FormHomePage(form, model);
form.add(new TextFieldString(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 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 CompoundPropertyModelCustomer(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 br...@brie.com 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 CompoundPropertyModelCustomer(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 ()
{
CompoundPropertyModelTeamMember  tm = new
CompoundPropertyModelTeamMember  (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:

table border=1
tr
td
span wicket:id=name/span
/td
td
img src=# alt= wicket:id=picture
/td
td
span wicket:id=age/span
/td
/tr
/table

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 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 http://jweekend.com/


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 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 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: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 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 
m...@software-by-mabe.comwrote:

 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
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 xavil...@gmail.com 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 chinedub...@gmail.com

 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 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 chinedub...@gmail.com

 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 xavil...@gmail.com 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 chinedub...@gmail.com
 
  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
you are absolutely correct. It worked perfectly thank you.

On Wed, Mar 3, 2010 at 12:07 PM, Xavier López xavil...@gmail.com 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 chinedub...@gmail.com

 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 xavil...@gmail.com 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 chinedub...@gmail.com
 
  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-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 chinedub...@gmail.com

 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 Николай Кучумов
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 Николай Кучумов kuchum...@gmail.com

 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 Николай Кучумов kuchum...@gmail.com

 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 a...@itbsllc.com

 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, Николай Кучумов kuchum...@gmail.com
  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-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 Николай Кучумов kuchum...@gmail.com

 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 Николай Кучумов kuchum...@gmail.com

 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 Николай Кучумов kuchum...@gmail.com

 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 a...@itbsllc.com

 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, Николай Кучумов kuchum...@gmail.com
  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-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 Николай Кучумов kuchum...@gmail.com

 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 a...@itbsllc.com

 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, Николай Кучумов kuchum...@gmail.com
  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 a...@itbsllc.com

 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, Николай Кучумов kuchum...@gmail.com
  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
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, Николай Кучумов kuchum...@gmail.comwrote:

 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 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, Николай Кучумов kuchum...@gmail.com
 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
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, Николай Кучумов kuchum...@gmail.comwrote:

 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, Николай Кучумов kuchum...@gmail.com
  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 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, Николай Кучумов kuchum...@gmail.com
 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 in conjunction with RadioChoiceChoiceRenderers

2009-11-04 Thread Sven Meier

Hi Xavier,


I suppose this error comes from having a ModelObject of type
String and also having a ChoiceRenderer refering to 'id' property


your choice is working on SimpleElementDTOs while your Person class has a 
String property - this cannot work.
Ideally you would just set a Department instance into your Person objects, but 
what you're trying to do can only be accomplished with a custom model.

Sven


Xavier López wrote:

Hi,

I have a question regarding the use of RadioChoice and ChoiceRenderer's in
conjunction with CompoundPropertyModel. I'm new to Wicket (but already a
convinced user ;) ), so maybe my approach on this one is not at all as it
should be... Any comments are welcome !

I'll get into details. Let's say I have a class in my domain model named
Person. This entity has a property named 'deptId' of type String. The Person
entity is the backing for a CompundPropertyModel applied to the whole form.
The 'deptId' field is inputted by the user, let's say, by means of a
RadioChoice (I guess it makes no difference from a DropDownChoice taking
into account the point of the question). The choice list for the RadioChoice
component is a List made up of DTO objects with properties id and
description. To ensure proper rendering of labels, I use a suitable
ChoiceRenderer.

Now, problems come when the 'deptId' property has a value in the Person
entity used in the CompoundPropertyModel. I get an error saying that class
String does not have any property called 'id' (I suppose this error comes
from having a ModelObject of type String and also having a ChoiceRenderer
refering to 'id' property).

I'll provide some sample code:

markup
-
...
form wicket:id=form
...
span valign=top wicket:id=deptId/span
...
/form
...

Java
-

...
ListSimpleElementDTO choices = contextData.getChoices();
Person p = new Person(...);
Form f = new Form(form){...};
f.setModel(new CompoundPropertyModel(p));
ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
ChoiceRenderer(id, description));
f.add(cr);
...


I suppose the 'normal' way of doing things would be providing a custom Model
to 'cr', but I'd like to know if there is a possibility to achieve this
point still using CompoundPropertyModel...

The stack trace I get is the following:

WicketMessage: No get method defined for class: class java.lang.String
expression: id
Root cause:
org.apache.wicket.WicketRuntimeException: No get method defined for class:
class java.lang.String expression: id
at
org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440)
at
org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282)
at
org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91)
at
org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140)
at
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144)
at
org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797)
at
org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407)
at org.apache.wicket.Component.renderComponent(Component.java:2480)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297)
...

  



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



Re: CompoundPropertyModel in conjunction with RadioChoiceChoiceRenderers

2009-11-04 Thread Pedro Santos
Hi Sven, he stell can write some specialized render... but I think the best
way is you have your depid property of type Department. Than all this thread
would not have started :)

class YourCustomRender
{
@Override
public String getIdValue(Object object, int index)
{
if (object instanceof DTO)
{
return ((DTO)object).getDeptId()
}
else
{
return (String)object;//already is the depid string
}
}

@Override
public Object getDisplayValue(Object object)
{
if (object instanceof DTO)
{
return ((DTO)object).getDescription();
}
else
{
return contextData.getDTOBasedOnDepid(object);
}
}
}

On Wed, Nov 4, 2009 at 1:29 PM, Xavier López xavil...@gmail.com wrote:

 Hi,

 I have a question regarding the use of RadioChoice and ChoiceRenderer's in
 conjunction with CompoundPropertyModel. I'm new to Wicket (but already a
 convinced user ;) ), so maybe my approach on this one is not at all as it
 should be... Any comments are welcome !

 I'll get into details. Let's say I have a class in my domain model named
 Person. This entity has a property named 'deptId' of type String. The
 Person
 entity is the backing for a CompundPropertyModel applied to the whole form.
 The 'deptId' field is inputted by the user, let's say, by means of a
 RadioChoice (I guess it makes no difference from a DropDownChoice taking
 into account the point of the question). The choice list for the
 RadioChoice
 component is a List made up of DTO objects with properties id and
 description. To ensure proper rendering of labels, I use a suitable
 ChoiceRenderer.

 Now, problems come when the 'deptId' property has a value in the Person
 entity used in the CompoundPropertyModel. I get an error saying that class
 String does not have any property called 'id' (I suppose this error comes
 from having a ModelObject of type String and also having a ChoiceRenderer
 refering to 'id' property).

 I'll provide some sample code:

 markup
 -
 ...
 form wicket:id=form
...
span valign=top wicket:id=deptId/span
...
 /form
 ...

 Java
 -

 ...
 ListSimpleElementDTO choices = contextData.getChoices();
 Person p = new Person(...);
 Form f = new Form(form){...};
 f.setModel(new CompoundPropertyModel(p));
 ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
 ChoiceRenderer(id, description));
 f.add(cr);
 ...


 I suppose the 'normal' way of doing things would be providing a custom
 Model
 to 'cr', but I'd like to know if there is a possibility to achieve this
 point still using CompoundPropertyModel...

 The stack trace I get is the following:

 WicketMessage: No get method defined for class: class java.lang.String
 expression: id
 Root cause:
 org.apache.wicket.WicketRuntimeException: No get method defined for class:
 class java.lang.String expression: id
 at

 org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440)
 at

 org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282)
 at

 org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91)
 at

 org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140)
 at

 org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144)
 at

 org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797)
 at

 org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407)
 at org.apache.wicket.Component.renderComponent(Component.java:2480)
 at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
 at org.apache.wicket.Component.render(Component.java:2317)
 at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297)
 ...




-- 
Pedro Henrique Oliveira dos Santos


Re: CompoundPropertyModel in conjunction with RadioChoiceChoiceRenderers

2009-11-04 Thread Sven Meier

Hi Pedro,

with your condition inside the renderer you've beaten me by originality ;).

But I doubt that the choice will be able to store the selected DTO in 
the entity's String property.


Sven

Pedro Santos wrote:

Hi Sven, he stell can write some specialized render... but I think the best
way is you have your depid property of type Department. Than all this thread
would not have started :)

class YourCustomRender
{
@Override
public String getIdValue(Object object, int index)
{
if (object instanceof DTO)
{
return ((DTO)object).getDeptId()
}
else
{
return (String)object;//already is the depid string
}
}

@Override
public Object getDisplayValue(Object object)
{
if (object instanceof DTO)
{
return ((DTO)object).getDescription();
}
else
{
return contextData.getDTOBasedOnDepid(object);
}
}
}

On Wed, Nov 4, 2009 at 1:29 PM, Xavier López xavil...@gmail.com wrote:

  

Hi,

I have a question regarding the use of RadioChoice and ChoiceRenderer's in
conjunction with CompoundPropertyModel. I'm new to Wicket (but already a
convinced user ;) ), so maybe my approach on this one is not at all as it
should be... Any comments are welcome !

I'll get into details. Let's say I have a class in my domain model named
Person. This entity has a property named 'deptId' of type String. The
Person
entity is the backing for a CompundPropertyModel applied to the whole form.
The 'deptId' field is inputted by the user, let's say, by means of a
RadioChoice (I guess it makes no difference from a DropDownChoice taking
into account the point of the question). The choice list for the
RadioChoice
component is a List made up of DTO objects with properties id and
description. To ensure proper rendering of labels, I use a suitable
ChoiceRenderer.

Now, problems come when the 'deptId' property has a value in the Person
entity used in the CompoundPropertyModel. I get an error saying that class
String does not have any property called 'id' (I suppose this error comes
from having a ModelObject of type String and also having a ChoiceRenderer
refering to 'id' property).

I'll provide some sample code:

markup
-
...
form wicket:id=form
   ...
   span valign=top wicket:id=deptId/span
   ...
/form
...

Java
-

...
ListSimpleElementDTO choices = contextData.getChoices();
Person p = new Person(...);
Form f = new Form(form){...};
f.setModel(new CompoundPropertyModel(p));
ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
ChoiceRenderer(id, description));
f.add(cr);
...


I suppose the 'normal' way of doing things would be providing a custom
Model
to 'cr', but I'd like to know if there is a possibility to achieve this
point still using CompoundPropertyModel...

The stack trace I get is the following:

WicketMessage: No get method defined for class: class java.lang.String
expression: id
Root cause:
org.apache.wicket.WicketRuntimeException: No get method defined for class:
class java.lang.String expression: id
at

org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440)
at

org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282)
at

org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91)
at

org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140)
at

org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144)
at

org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797)
at

org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407)
at org.apache.wicket.Component.renderComponent(Component.java:2480)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297)
...






  



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



Re: CompoundPropertyModel in conjunction with RadioChoiceChoiceRenderers

2009-11-04 Thread Xavier López
Hi Sven, Pedro,

Thanks both for your quick reply.

Ideally you would just set a Department instance into your Person objects


the best way is you have your depid property of type Department

This was the first approach to take into account, but the idea was discarded
in benefit of SimpleElementDTO, in order to provide only the necessary
information to Wicket Models, with the intention of not wasting any memory
on PageMaps due to Department object serializations... Also, this
SimpleElementDTO would be reusable throughout the whole application when
it's about Radio and DropDown Choices...

write some specialized render

This kinda 'dirty-fix' idea was already crawling in my mind, trying to come
out someway. Thanks for providing a concrete implementation.

So, in the end I'm trying to provide a custom model. Something like:

Java

final Person p;

Model crModel = new Model(){
  getObject(){
 return p.getDeptId();
   }
  setObject(Object o){
 // o is String!
 p.setDeptId( (String) o);
  }
};
ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
ChoiceRenderer(id, description));
cr.setModel(crModel);

But i'm stucking into the same error, as this Model it's kind like a
PropertyModel which would be assumed by having the former
CompoundPropertyModel...

Any thoughts ? Maybe rendering labels independently ?

It's strange nobody has bumped into this situation before.. Maybe it's
because i'm still thinking like I was using Struts...

Thanks to both again,
Cheers !


2009/11/4 Pedro Santos pedros...@gmail.com

 Hi Sven, he stell can write some specialized render... but I think the best
 way is you have your depid property of type Department. Than all this
 thread
 would not have started :)

 class YourCustomRender
{
@Override
public String getIdValue(Object object, int index)
{
if (object instanceof DTO)
{
return ((DTO)object).getDeptId()
}
else
{
return (String)object;//already is the depid string
}
}

@Override
public Object getDisplayValue(Object object)
{
if (object instanceof DTO)
{
return ((DTO)object).getDescription();
}
else
{
return contextData.getDTOBasedOnDepid(object);
 }
}
}

 On Wed, Nov 4, 2009 at 1:29 PM, Xavier López xavil...@gmail.com wrote:

  Hi,
 
  I have a question regarding the use of RadioChoice and ChoiceRenderer's
 in
  conjunction with CompoundPropertyModel. I'm new to Wicket (but already a
  convinced user ;) ), so maybe my approach on this one is not at all as it
  should be... Any comments are welcome !
 
  I'll get into details. Let's say I have a class in my domain model named
  Person. This entity has a property named 'deptId' of type String. The
  Person
  entity is the backing for a CompundPropertyModel applied to the whole
 form.
  The 'deptId' field is inputted by the user, let's say, by means of a
  RadioChoice (I guess it makes no difference from a DropDownChoice taking
  into account the point of the question). The choice list for the
  RadioChoice
  component is a List made up of DTO objects with properties id and
  description. To ensure proper rendering of labels, I use a suitable
  ChoiceRenderer.
 
  Now, problems come when the 'deptId' property has a value in the Person
  entity used in the CompoundPropertyModel. I get an error saying that
 class
  String does not have any property called 'id' (I suppose this error comes
  from having a ModelObject of type String and also having a ChoiceRenderer
  refering to 'id' property).
 
  I'll provide some sample code:
 
  markup
  -
  ...
  form wicket:id=form
 ...
 span valign=top wicket:id=deptId/span
 ...
  /form
  ...
 
  Java
  -
 
  ...
  ListSimpleElementDTO choices = contextData.getChoices();
  Person p = new Person(...);
  Form f = new Form(form){...};
  f.setModel(new CompoundPropertyModel(p));
  ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
  ChoiceRenderer(id, description));
  f.add(cr);
  ...
 
 
  I suppose the 'normal' way of doing things would be providing a custom
  Model
  to 'cr', but I'd like to know if there is a possibility to achieve this
  point still using CompoundPropertyModel...
 
  The stack trace I get is the following:
 
  WicketMessage: No get method defined for class: class java.lang.String
  expression: id
  Root cause:
  org.apache.wicket.WicketRuntimeException: No get method defined for
 class:
  class java.lang.String expression: id
  at
 
 
 org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440)
  at
 
 
 org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282)
  at
 
 
 

Re: CompoundPropertyModel in conjunction with RadioChoiceChoiceRenderers

2009-11-04 Thread Pedro Santos
Model crModel = new Model(){
 getObject(){
return contextData.getDTO(p.getDeptId());
  }
 setObject(Object o){
p.setDeptId( ((DTO) o).getId());
 }
};

On Wed, Nov 4, 2009 at 2:32 PM, Xavier López xavil...@gmail.com wrote:

 Hi Sven, Pedro,

 Thanks both for your quick reply.

 Ideally you would just set a Department instance into your Person objects


 the best way is you have your depid property of type Department

 This was the first approach to take into account, but the idea was
 discarded
 in benefit of SimpleElementDTO, in order to provide only the necessary
 information to Wicket Models, with the intention of not wasting any memory
 on PageMaps due to Department object serializations... Also, this
 SimpleElementDTO would be reusable throughout the whole application when
 it's about Radio and DropDown Choices...

 write some specialized render
 
 This kinda 'dirty-fix' idea was already crawling in my mind, trying to come
 out someway. Thanks for providing a concrete implementation.

 So, in the end I'm trying to provide a custom model. Something like:

 Java
 
 final Person p;

 Model crModel = new Model(){
  getObject(){
 return p.getDeptId();
   }
  setObject(Object o){
 // o is String!
 p.setDeptId( (String) o);
   }
 };
 ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
 ChoiceRenderer(id, description));
 cr.setModel(crModel);

 But i'm stucking into the same error, as this Model it's kind like a
 PropertyModel which would be assumed by having the former
 CompoundPropertyModel...

 Any thoughts ? Maybe rendering labels independently ?

 It's strange nobody has bumped into this situation before.. Maybe it's
 because i'm still thinking like I was using Struts...

 Thanks to both again,
 Cheers !


 2009/11/4 Pedro Santos pedros...@gmail.com

  Hi Sven, he stell can write some specialized render... but I think the
 best
  way is you have your depid property of type Department. Than all this
  thread
  would not have started :)
 
  class YourCustomRender
 {
 @Override
 public String getIdValue(Object object, int index)
 {
 if (object instanceof DTO)
 {
 return ((DTO)object).getDeptId()
 }
 else
 {
 return (String)object;//already is the depid string
 }
 }
 
 @Override
 public Object getDisplayValue(Object object)
 {
 if (object instanceof DTO)
 {
 return ((DTO)object).getDescription();
 }
 else
 {
 return contextData.getDTOBasedOnDepid(object);
  }
 }
 }
 
  On Wed, Nov 4, 2009 at 1:29 PM, Xavier López xavil...@gmail.com wrote:
 
   Hi,
  
   I have a question regarding the use of RadioChoice and ChoiceRenderer's
  in
   conjunction with CompoundPropertyModel. I'm new to Wicket (but already
 a
   convinced user ;) ), so maybe my approach on this one is not at all as
 it
   should be... Any comments are welcome !
  
   I'll get into details. Let's say I have a class in my domain model
 named
   Person. This entity has a property named 'deptId' of type String. The
   Person
   entity is the backing for a CompundPropertyModel applied to the whole
  form.
   The 'deptId' field is inputted by the user, let's say, by means of a
   RadioChoice (I guess it makes no difference from a DropDownChoice
 taking
   into account the point of the question). The choice list for the
   RadioChoice
   component is a List made up of DTO objects with properties id and
   description. To ensure proper rendering of labels, I use a suitable
   ChoiceRenderer.
  
   Now, problems come when the 'deptId' property has a value in the Person
   entity used in the CompoundPropertyModel. I get an error saying that
  class
   String does not have any property called 'id' (I suppose this error
 comes
   from having a ModelObject of type String and also having a
 ChoiceRenderer
   refering to 'id' property).
  
   I'll provide some sample code:
  
   markup
   -
   ...
   form wicket:id=form
  ...
  span valign=top wicket:id=deptId/span
  ...
   /form
   ...
  
   Java
   -
  
   ...
   ListSimpleElementDTO choices = contextData.getChoices();
   Person p = new Person(...);
   Form f = new Form(form){...};
   f.setModel(new CompoundPropertyModel(p));
   ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
   ChoiceRenderer(id, description));
   f.add(cr);
   ...
  
  
   I suppose the 'normal' way of doing things would be providing a custom
   Model
   to 'cr', but I'd like to know if there is a possibility to achieve this
   point still using CompoundPropertyModel...
  
   The stack trace I get is the following:
  
   WicketMessage: No get method defined for class: class java.lang.String
   expression: 

Re: CompoundPropertyModel in conjunction with RadioChoiceChoiceRenderers

2009-11-04 Thread Xavier López
Wonderful !

Now I understand better. If only I could set the String deptId in an inner
variable inside the Model and link it to the property with another model !
This comes from the fact that the building of the RadioChoice is made inside
a Helper Class...

Probably this is an atrocity, but I hope it'll transmit the idea...

Helper.java
--
public static RadioChoice getDeptRadioChoice(String id){
RadioChoice cr = new RadioChoice(id,
getDeptsAsDTOList(),
new SimpleElementChoiceRenderer());

Model crModel = new Model(){
String id;
getObject(){
return getDptDTO(id);
}
setObject(Object o){
id = ( ((DTO) o).getId());
}
};
cr.setModel(crModel);
return cr;
}

PersonForm.java
-

RadioChoice cr = Helper.getDeptRadioChoice(deptId);
cr.setModel(new Model(cr.getModel()){
public Object getObject(){
return ((Model)super.getObject()).getObject();
}
public void setObject(Object o){
((Model)getObject()).setObject(o);
p.setDeptId((String)m.getObject());
}
});

Thanks !

2009/11/4 Pedro Santos pedros...@gmail.com

 Model crModel = new Model(){
 getObject(){
 return contextData.getDTO(p.getDeptId());
  }
 setObject(Object o){
p.setDeptId( ((DTO) o).getId());
 }
 };

 On Wed, Nov 4, 2009 at 2:32 PM, Xavier López xavil...@gmail.com wrote:

  Hi Sven, Pedro,
 
  Thanks both for your quick reply.
 
  Ideally you would just set a Department instance into your Person objects
 
 
  the best way is you have your depid property of type Department
 
  This was the first approach to take into account, but the idea was
  discarded
  in benefit of SimpleElementDTO, in order to provide only the necessary
  information to Wicket Models, with the intention of not wasting any
 memory
  on PageMaps due to Department object serializations... Also, this
  SimpleElementDTO would be reusable throughout the whole application when
  it's about Radio and DropDown Choices...
 
  write some specialized render
  
  This kinda 'dirty-fix' idea was already crawling in my mind, trying to
 come
  out someway. Thanks for providing a concrete implementation.
 
  So, in the end I'm trying to provide a custom model. Something like:
 
  Java
  
  final Person p;
 
  Model crModel = new Model(){
   getObject(){
  return p.getDeptId();
}
   setObject(Object o){
  // o is String!
  p.setDeptId( (String) o);
}
  };
  ChoiceRenderer cr = new ChoiceRenderer(deptId, choices, new
  ChoiceRenderer(id, description));
  cr.setModel(crModel);
 
  But i'm stucking into the same error, as this Model it's kind like a
  PropertyModel which would be assumed by having the former
  CompoundPropertyModel...
 
  Any thoughts ? Maybe rendering labels independently ?
 
  It's strange nobody has bumped into this situation before.. Maybe it's
  because i'm still thinking like I was using Struts...
 
  Thanks to both again,
  Cheers !
 
 
  2009/11/4 Pedro Santos pedros...@gmail.com
 
   Hi Sven, he stell can write some specialized render... but I think the
  best
   way is you have your depid property of type Department. Than all this
   thread
   would not have started :)
  
   class YourCustomRender
  {
  @Override
  public String getIdValue(Object object, int index)
  {
  if (object instanceof DTO)
  {
  return ((DTO)object).getDeptId()
  }
  else
  {
  return (String)object;//already is the depid string
  }
  }
  
  @Override
  public Object getDisplayValue(Object object)
  {
  if (object instanceof DTO)
  {
  return ((DTO)object).getDescription();
  }
  else
  {
  return contextData.getDTOBasedOnDepid(object);
   }
  }
  }
  
   On Wed, Nov 4, 2009 at 1:29 PM, Xavier López xavil...@gmail.com
 wrote:
  
Hi,
   
I have a question regarding the use of RadioChoice and
 ChoiceRenderer's
   in
conjunction with CompoundPropertyModel. I'm new to Wicket (but
 already
  a
convinced user ;) ), so maybe my approach on this one is not at all
 as
  it
should be... Any comments are welcome !
   
I'll get into details. Let's say I have a class in my domain model
  named
Person. This entity has a property named 'deptId' of type String. The
Person
entity is the backing for a CompundPropertyModel applied to the whole
   form.
The 'deptId' field is inputted by the user, let's say, by means of a
RadioChoice (I guess 

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, Bobbybobby.hubb...@garmin.com 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!!



 code

 ...

 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);

 }...

 /code



 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 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, Bobbybobby.hubb...@garmin.com 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!!



 code

 ...

 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);

 }...

 /code



 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 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, Bobbybobby.hubb...@garmin.com 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, Bobbybobby.hubb...@garmin.com 
 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!!



 code

 ...

 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);

 }...

 /code



 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 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
Thomersonjer...@wickettraining.com 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, Bobbybobby.hubb...@garmin.com 
 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, Bobbybobby.hubb...@garmin.com 
 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!!



 code

 ...

 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);

 }...

 /code



 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 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 {

nbsp;nbsp;nbsp;nbsp;private final ImovelHabitacionalInput
imovelHabitacionalInput = new ImovelHabitacionalInput();


nbsp;nbsp;nbsp;nbsp;...


nbsp;nbsp;nbsp;nbsp;public ImovelHabitacionalForm() {

nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;super(ID);


nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;setModel(new
CompoundPropertyModel(imovelHabitacionalInput));


nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;buildForm();

nbsp;nbsp;nbsp;nbsp;}


nbsp;nbsp;nbsp;nbsp;/*The components creations */


nbsp;nbsp;nbsp;nbsp;private void buildForm() {

nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*TRANSACTION TYPES*/

nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;List transactionTypes =
TipoTransaccaoFacade.getTipoTransaccoes();

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


nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*DISTRICTS*/

nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;DistritosModel
distritosModel = new DistritosModel();

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

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


nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*PRICE*/

nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;priceTextField = new
TextField(price);


nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*AREA*/

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

nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;private TextFieldAreaModel
areaModel = new TextFieldAreaModel();

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

nbsp;nbsp;nbsp;nbsp;}

}


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

private class ImovelHabitacionalInput implements IClusterable {

nbsp;nbsp;nbsp;nbsp;private String district= ;
 
nbsp;nbsp;nbsp;nbsp;private String transactionType= ;


nbsp;nbsp;nbsp;nbsp;private String price= ;

nbsp;nbsp;nbsp;nbsp;private String area = ;


nbsp;nbsp;nbsp;nbsp;/*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;
   

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 ListString stringList;

public static ListString asStringList() {
if (stringList == null) {
stringList = new ArrayListString();
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 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 HashMapString, Object();

 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-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 HashMapString, Object();

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 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 EditorModelT extends CompoundPropertyModelT {
   private final MapString, Object newValues = new HashMapString,
Object();
   public EditorModel(IModelT underlyingModel) {
 super(underlyingModel);
 }
   public void fillOriginal() {
   Class? c = this.getObject().getClass();
   for (EntryString, Object 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 C IWrapModelC wrapOnInheritance(Component component) {
 return new AttachedCompoundPropertyModelC(component,
newValues);
 }
   private class AttachedCompoundPropertyModelC extends
 AbstractPropertyModelC implements IWrapModelC {
 private static final long serialVersionUID = 1L;
   private final Component owner;
   private final MapString, Object newValues;
   /**
  * Constructor
  *
  * @param owner
  *component that this model has been attached to
  */
 public AttachedCompoundPropertyModel(Component owner,
MapString,Object 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 IModelT 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:



 

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 EditorModelT extends CompoundPropertyModelT {
 private final MapString, Object newValues = new HashMapString,
 Object();
 public EditorModel(IModelT underlyingModel) {
   super(underlyingModel);
   }
 public void fillOriginal() {
 Class? c = this.getObject().getClass();
 for (EntryString, Object 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 C IWrapModelC wrapOnInheritance(Component component) {
   return new AttachedCompoundPropertyModelC(component,
 newValues);
   }
 private class AttachedCompoundPropertyModelC extends
   AbstractPropertyModelC implements IWrapModelC {
   private static final long serialVersionUID = 1L;
 private final Component owner;
 private final MapString, Object newValues;
 /**
* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner,
 MapString,Object 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 IModelT 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 HashMapString, Object();
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 

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 EditorModelT extends CompoundPropertyModelT {
private final MapString, Object newValues = new HashMapString,
Object();
public EditorModel(IModelT underlyingModel) {
  super(underlyingModel);
  }
public void fillOriginal() {
Class? c = this.getObject().getClass();
for (EntryString, Object 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 C IWrapModelC wrapOnInheritance(Component component) {
  return new AttachedCompoundPropertyModelC(component,
newValues);
  }
private class AttachedCompoundPropertyModelC extends
  AbstractPropertyModelC implements IWrapModelC {
  private static final long serialVersionUID = 1L;
private final Component owner;
private final MapString, Object newValues;
/**
   * Constructor
   *
   * @param owner
   *component that this model has been attached to
   */
  public AttachedCompoundPropertyModel(Component owner,
MapString,Object 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 IModelT 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 HashMapString, 

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 EditorModelT extends CompoundPropertyModelT {
private final MapString, Object newValues = new HashMapString,
 Object();
public EditorModel(IModelT underlyingModel) {
  super(underlyingModel);
  }
public void fillOriginal() {
Class? c = this.getObject().getClass();
for (EntryString, Object 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 C IWrapModelC wrapOnInheritance(Component component) {
  return new AttachedCompoundPropertyModelC(component,
 newValues);
  }
private class AttachedCompoundPropertyModelC extends
  AbstractPropertyModelC implements IWrapModelC {
  private static final long serialVersionUID = 1L;
private final Component owner;
private final MapString, Object newValues;
/**
   * Constructor
   *
   * @param owner
   *component that this model has been attached to
   */
  public AttachedCompoundPropertyModel(Component owner,
 MapString,Object 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 IModelT 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, 

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 EditorModelT extends CompoundPropertyModelT {
 private final MapString, Object newValues = new 
HashMapString, Object();

 public EditorModel(IModelT underlyingModel) {
   super(underlyingModel);
   }
 public void fillOriginal() {
 Class? c = this.getObject().getClass();
 for (EntryString, Object 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 C IWrapModelC wrapOnInheritance(Component 
component) {
   return new AttachedCompoundPropertyModelC(component, 
newValues);

   }
 private class AttachedCompoundPropertyModelC extends
   AbstractPropertyModelC implements IWrapModelC {
   private static final long serialVersionUID = 1L;
 private final Component owner;
 private final MapString, Object newValues;
 /**
* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner, 
MapString,Object 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 IModelT 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 HashMapString, Object();
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 

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 HashMapString, Object();
 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
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 HashMapString, Object();
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 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 EditorModelT extends CompoundPropertyModelT {
  
   private final MapString, Object newValues = new 
HashMapString, Object();
  
   public EditorModel(IModelT underlyingModel) {

   super(underlyingModel);
   }
  
   public void fillOriginal() {
  
   Class? c = this.getObject().getClass();
  
   for (EntryString, Object 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 C IWrapModelC wrapOnInheritance(Component component) {
   return new AttachedCompoundPropertyModelC(component, 
newValues);

   }
  
   private class AttachedCompoundPropertyModelC extends

   AbstractPropertyModelC implements IWrapModelC {
   private static final long serialVersionUID = 1L;
  
   private final Component owner;
  
   private final MapString, Object newValues;
  
   /**

* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner, 
MapString,Object 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 IModelT 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 HashMapString, Object();
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

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 HashMapString, Object();
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 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 HashMapString, Object();
 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 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 ShadowCompoundPropertyModelT extends
 CompoundPropertyModelT {

   private final MapString, Object newValues = new HashMapString,
 Object();

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

   public void fillOriginal() {
   for (EntryString, Object entry : newValues.entrySet()) {

   PropertyResolverConverter prc = null;
   prc = new
 PropertyResolverConverter(Application.get().getConverterLocator(),
   Session.get().getLocale());
   PropertyResolver.setValue(entry.getKey(), getObject(),
 entry.getValue(), prc);
   }
   }

   public C IWrapModelC wrapOnInheritance(Component component) {
   return new AttachedCompoundPropertyModelC(component, newValues);
   }

   private class AttachedCompoundPropertyModelC extends
   AbstractPropertyModelC implements IWrapModelC {
   private static final long serialVersionUID = 1L;

   private final Component owner;

   private final MapString, Object newValues;

   /**
* Constructor
*
* @param owner
*component that this model has been attached to
*/
   public AttachedCompoundPropertyModel(Component owner,
   MapString, Object 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 IModelT 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 HashMapString, Object();
 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
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());
}

});


ul
li wicket:id=phones
input type=text wicket:id=number /
/li
/ul


-- 
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 ListPhone 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 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());
 }

 });


 ul
 li wicket:id=phones
 input type=text wicket:id=number /
 /li
 /ul


 --
 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 ListPhone 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 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 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 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 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-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 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-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-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 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 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-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-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]



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

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 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