could not find component x on page y error

2013-05-08 Thread Giovanni Cuccu

Hi,
   I'm facing a random error and I'm not able to trace its cause.
The error is
'could not find component x on page y error'
The problem is that the component named x has never been on page y.
The component name reported in the error is an old one (which is not in 
the jar app anymore) and it was orginally on another page.
I did delete the filestore files in the last deploy so I don't know 
where the app is taking the reference to x component.
I have no ajax replace on the page y and there waere no ajax replace on 
the original page either.

The user actions are the following
the user tries to load the app using an url that point to a protected 
(i.e required login) page

the page being requested is expired
the user get redirect to a login page
the user does some operations successfully
the user sleeps for the session expiration period
the user select a page anf got the error
I have a special Logback logger that put the logging events (SLF4J) of a 
single logged user into a thread local variable and on error it dumps a 
file; I don't know it this can be related to the error, so I put it on 
the table.

Can anyone suggest a way to find the cause of this error?
Thanks,
   Giovanni

--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: could not find component x on page y error

2013-05-08 Thread Giovanni Cuccu

Hi,
I'm using wicket 6.6.
thanks,
   Giovanni
Il 08/05/13 12:52, Giovanni Cuccu ha scritto:

Hi,
   I'm facing a random error and I'm not able to trace its cause.
The error is
'could not find component x on page y error'
The problem is that the component named x has never been on page y.
The component name reported in the error is an old one (which is not 
in the jar app anymore) and it was orginally on another page.
I did delete the filestore files in the last deploy so I don't know 
where the app is taking the reference to x component.
I have no ajax replace on the page y and there waere no ajax replace 
on the original page either.

The user actions are the following
the user tries to load the app using an url that point to a protected 
(i.e required login) page

the page being requested is expired
the user get redirect to a login page
the user does some operations successfully
the user sleeps for the session expiration period
the user select a page anf got the error
I have a special Logback logger that put the logging events (SLF4J) of 
a single logged user into a thread local variable and on error it 
dumps a file; I don't know it this can be related to the error, so I 
put it on the table.

Can anyone suggest a way to find the cause of this error?
Thanks,
   Giovanni



--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Semi OT: Request for on site wicket training

2013-04-09 Thread Giovanni Cuccu

Hi,
   I'm trying to convince my boss to invest in a wicket course, and he 
wants for a quotation (read $ or €) in order to evaluate to go on or not.
I'm looking for a wicket  on site course for about 10 developers 
(Location Bologna, Italy) three or five days long.
We are using wicket since 2009 and we need to check out daily habits and 
how to improve our code/skills.

The details are to be defined but my first idea about the contents are
1)recap on wicket models (with an emphasis on detachable models that we 
are not using)
2)How to solve some common problems (Panel vs FormComponentPanel, nested 
forms) in managing complex forms
3)Ajax: the basics and how to solve common problems (triggering updates 
on other components, etc)

4)Wicket tester and testing of wicket applications
5)Some wicket internals
We are using wicket 1.5 but we also have some projects using wicket 6 
and we are starting the migration to from 1.5 to 6.
The course must be in italian and/or in english; estimated period late 
june/july 2013 (june is also a nice month for comin in Italy for vacations)

If interested please answer to me directly (i.e. off-list)
Grazie,
 Giovanni


--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Giovanni Cuccu

ciao,
I think Autocompletetextfield deals only with String.
IIRC there is a objectautocomplete in wicketstuff.
I did not use it personally but I suppose that does what you need.
Giovanni

Il 01/08/12 12.31, Daniele Dellafiore ha scritto:

Hi.

I'm sure I'm talking about something that has already been discussed
here and on stackoverflow a lot, but still I haven't found a solution.

I do not understand how AutocompleteTextField works when dealing with
list of objects that are not just strings. Other wicket components
like DropDown has a clear pattern: the renderer is used only for
rendering purpose, there's a model to store selection and a model to
store choices options.

Still, I can't figure out how to do the very same thing with
AutocompleteTextField.

The best I can get is:
TextField codeField = new 
AutoCompleteTextFieldJSONObject(code,
model, JSONObject.class, renderer,
  new AutoCompleteSettings());


I'm using an AbstractAutoCompleteTextRenderer and a PropertyModel
binded to a JSONObject variable.
It all works but when I submit the form, it says me that the selected
string is not a valid JSONObject, so he cannot attach it to the field.

the ITerator returned by AutocompleteTextField.getChoices(String
input) is an Iterator of JSONObject.
I expect that when I submit, the setObject receives the selected
JSONObject, not the String I do render using a specific Renderer.

How can that be done?

Thanks anyone for help.



--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: Unable to use wicket tester to simulate ajax behavior

2012-07-24 Thread Giovanni Cuccu

Hi,
sorry for the late response. Should I file a bug for this?
Thanks,
Giovanni
Il 11/07/12 15.13, Giovanni Cuccu ha scritto:

Hi Martin,
 I did the change you suggested but the test fails with esame error:

junit.framework.AssertionFailedError: expect no error message, but 
contains

   Field 'combo1' is required.

Thanks,
 Giovanni
Il 11/07/12 09.23, Martin Grigorov ha scritto:

Hi,

Try with:

tester.getRequest().setParameter(form:combo1, 0);
tester.executeAjaxEvent(form:combo1, onchange);

On Tue, Jul 10, 2012 at 10:10 AM, Giovanni Cuccu
giovanni.cu...@cup2000.it wrote:

Hi,
 can someone give me an hint on this?
I tried to explain my problem providing a complete example and 
explaining

what I was trying to achieve.
I'd like to know if there is a specific reason of getting no answer 
so I can

change something on my side the next time I need to write to the list.
Thanks,
 Giovanni
Il 05/07/12 08.10, Giovanni Cuccu ha scritto:


Hi all,
 I'm trying to test a wicket 1.5.7 application and I'm hitting a
strange (at least for me) issue.
I have two dropdowns (combo 1 and combo2) and when I select one value
from combo1 I fire an AjaxUpdateBehavior on onchange event which 
selects

a value on combo2.
If I use the application everything is working as expected but If I 
try

to simulate the application with wicket tester I come into trouble.
Basically the test code is the following one:

 WicketTester tester= new WicketTester(new 
WicketApplication());

 tester.startPage(TestAjaxDropDown.class);
 FormTester formTester=tester.newFormTester(form);
 formTester.select(combo1, 0);
 tester.executeAjaxEvent(form:combo1, onchange);
 formTester.submit();
 tester.assertNoErrorMessage();

what I got is that after firing the onchange event combo1 gets a null
value as object model and this does not happen when I use a 
browser. If

I do not fire the event the application reports that combo2 has no
element selected.
Am I  missing something or is it a bug?

Grazie,
   Giovanni

P.S. I built a simple test case that I insert here

main page class

package com.sg2net.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.PropertyModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class TestAjaxDropDown extends WebPage {

 private static final Logger
logger=LoggerFactory.getLogger(TestAjaxDropDown.class.getName());

 public TestAjaxDropDown() {
 add(new FeedbackPanel(feedback));
 add(new TestAjaxDropDownFrom(form));
 }

 private class DomainObject1 implements Serializable {
 public DomainObject1(long id, String description) {
 super();
 this.id = id;
 this.description = description;
 }
 private static final long serialVersionUID = 1L;
 private long id;
 private String description;

 public long getId() {
 return id;
 }
 public void setId(long id) {
 this.id = id;
 }
 public String getDescription() {
 return description;
 }
 public void setDescription(String description) {
 this.description = description;
 }
 @Override
 public int hashCode() {
 final int prime = 31;
 int result = 1;
 result = prime * result + getOuterType().hashCode();
 result = prime * result + (int) (id ^ (id  32));
 return result;
 }
 @Override
 public boolean equals(Object obj) {
 if (this == obj)
 return true;
 if (obj == null)
 return false;
 if (getClass() != obj.getClass())
 return false;
 DomainObject1 other = (DomainObject1) obj;
 if (!getOuterType().equals(other.getOuterType()))
 return false;
 if (id != other.id)
 return false;
 return true;
 }
 private TestAjaxDropDown getOuterType() {
 return TestAjaxDropDown.this;
 }

 }

 private class DomainObject2 implements Serializable {
 public DomainObject2(long id, String description) {
 super();
 this.id = id;
 this.description = description;
 }
 private static final long serialVersionUID = 1L;
 private long id;
 private String description;

 public long

Re: Unable to use wicket tester to simulate ajax behavior

2012-07-24 Thread Giovanni Cuccu

Hi,
  here it is
https://issues.apache.org/jira/browse/WICKET-4670
Thanks,
  Giovanni

Il 24/07/12 09.22, Martin Grigorov ha scritto:

Hi,

File a ticket with a test case.

On Tue, Jul 24, 2012 at 9:34 AM, Giovanni Cuccu
giovanni.cu...@cup2000.it wrote:

Hi,
 sorry for the late response. Should I file a bug for this?
Thanks,
 Giovanni
Il 11/07/12 15.13, Giovanni Cuccu ha scritto:


Hi Martin,
  I did the change you suggested but the test fails with esame error:

junit.framework.AssertionFailedError: expect no error message, but
contains
Field 'combo1' is required.

Thanks,
  Giovanni
Il 11/07/12 09.23, Martin Grigorov ha scritto:

Hi,

Try with:

tester.getRequest().setParameter(form:combo1, 0);
tester.executeAjaxEvent(form:combo1, onchange);

On Tue, Jul 10, 2012 at 10:10 AM, Giovanni Cuccu
giovanni.cu...@cup2000.it wrote:

Hi,
  can someone give me an hint on this?
I tried to explain my problem providing a complete example and
explaining
what I was trying to achieve.
I'd like to know if there is a specific reason of getting no answer so I
can
change something on my side the next time I need to write to the list.
Thanks,
  Giovanni
Il 05/07/12 08.10, Giovanni Cuccu ha scritto:


Hi all,
  I'm trying to test a wicket 1.5.7 application and I'm hitting a
strange (at least for me) issue.
I have two dropdowns (combo 1 and combo2) and when I select one value
from combo1 I fire an AjaxUpdateBehavior on onchange event which
selects
a value on combo2.
If I use the application everything is working as expected but If I try
to simulate the application with wicket tester I come into trouble.
Basically the test code is the following one:

  WicketTester tester= new WicketTester(new
WicketApplication());
  tester.startPage(TestAjaxDropDown.class);
  FormTester formTester=tester.newFormTester(form);
  formTester.select(combo1, 0);
  tester.executeAjaxEvent(form:combo1, onchange);
  formTester.submit();
  tester.assertNoErrorMessage();

what I got is that after firing the onchange event combo1 gets a null
value as object model and this does not happen when I use a browser. If
I do not fire the event the application reports that combo2 has no
element selected.
Am I  missing something or is it a bug?

Grazie,
Giovanni

P.S. I built a simple test case that I insert here

main page class

package com.sg2net.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.PropertyModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class TestAjaxDropDown extends WebPage {

  private static final Logger
logger=LoggerFactory.getLogger(TestAjaxDropDown.class.getName());

  public TestAjaxDropDown() {
  add(new FeedbackPanel(feedback));
  add(new TestAjaxDropDownFrom(form));
  }

  private class DomainObject1 implements Serializable {
  public DomainObject1(long id, String description) {
  super();
  this.id = id;
  this.description = description;
  }
  private static final long serialVersionUID = 1L;
  private long id;
  private String description;

  public long getId() {
  return id;
  }
  public void setId(long id) {
  this.id = id;
  }
  public String getDescription() {
  return description;
  }
  public void setDescription(String description) {
  this.description = description;
  }
  @Override
  public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + getOuterType().hashCode();
  result = prime * result + (int) (id ^ (id  32));
  return result;
  }
  @Override
  public boolean equals(Object obj) {
  if (this == obj)
  return true;
  if (obj == null)
  return false;
  if (getClass() != obj.getClass())
  return false;
  DomainObject1 other = (DomainObject1) obj;
  if (!getOuterType().equals(other.getOuterType()))
  return false;
  if (id != other.id)
  return false;
  return true;
  }
  private TestAjaxDropDown getOuterType() {
  return TestAjaxDropDown.this;
  }

  }

  private class DomainObject2 implements

Re: Unable to use wicket tester to simulate ajax behavior

2012-07-11 Thread Giovanni Cuccu

Hi Martin,
 I did the change you suggested but the test fails with esame error:

junit.framework.AssertionFailedError: expect no error message, but contains
   Field 'combo1' is required.

Thanks,
 Giovanni
Il 11/07/12 09.23, Martin Grigorov ha scritto:

Hi,

Try with:

tester.getRequest().setParameter(form:combo1, 0);
tester.executeAjaxEvent(form:combo1, onchange);

On Tue, Jul 10, 2012 at 10:10 AM, Giovanni Cuccu
giovanni.cu...@cup2000.it wrote:

Hi,
 can someone give me an hint on this?
I tried to explain my problem providing a complete example and explaining
what I was trying to achieve.
I'd like to know if there is a specific reason of getting no answer so I can
change something on my side the next time I need to write to the list.
Thanks,
 Giovanni
Il 05/07/12 08.10, Giovanni Cuccu ha scritto:


Hi all,
 I'm trying to test a wicket 1.5.7 application and I'm hitting a
strange (at least for me) issue.
I have two dropdowns (combo 1 and combo2) and when I select one value
from combo1 I fire an AjaxUpdateBehavior on onchange event which selects
a value on combo2.
If I use the application everything is working as expected but If I try
to simulate the application with wicket tester I come into trouble.
Basically the test code is the following one:

 WicketTester tester= new WicketTester(new WicketApplication());
 tester.startPage(TestAjaxDropDown.class);
 FormTester formTester=tester.newFormTester(form);
 formTester.select(combo1, 0);
 tester.executeAjaxEvent(form:combo1, onchange);
 formTester.submit();
 tester.assertNoErrorMessage();

what I got is that after firing the onchange event combo1 gets a null
value as object model and this does not happen when I use a browser. If
I do not fire the event the application reports that combo2 has no
element selected.
Am I  missing something or is it a bug?

Grazie,
   Giovanni

P.S. I built a simple test case that I insert here

main page class

package com.sg2net.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.PropertyModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class TestAjaxDropDown extends WebPage {

 private static final Logger
logger=LoggerFactory.getLogger(TestAjaxDropDown.class.getName());

 public TestAjaxDropDown() {
 add(new FeedbackPanel(feedback));
 add(new TestAjaxDropDownFrom(form));
 }

 private class DomainObject1 implements Serializable {
 public DomainObject1(long id, String description) {
 super();
 this.id = id;
 this.description = description;
 }
 private static final long serialVersionUID = 1L;
 private long id;
 private String description;

 public long getId() {
 return id;
 }
 public void setId(long id) {
 this.id = id;
 }
 public String getDescription() {
 return description;
 }
 public void setDescription(String description) {
 this.description = description;
 }
 @Override
 public int hashCode() {
 final int prime = 31;
 int result = 1;
 result = prime * result + getOuterType().hashCode();
 result = prime * result + (int) (id ^ (id  32));
 return result;
 }
 @Override
 public boolean equals(Object obj) {
 if (this == obj)
 return true;
 if (obj == null)
 return false;
 if (getClass() != obj.getClass())
 return false;
 DomainObject1 other = (DomainObject1) obj;
 if (!getOuterType().equals(other.getOuterType()))
 return false;
 if (id != other.id)
 return false;
 return true;
 }
 private TestAjaxDropDown getOuterType() {
 return TestAjaxDropDown.this;
 }

 }

 private class DomainObject2 implements Serializable {
 public DomainObject2(long id, String description) {
 super();
 this.id = id;
 this.description = description;
 }
 private static final long serialVersionUID = 1L;
 private long id;
 private String description;

 public long getId() {
 return id;
 }
 public void setId(long id) {
 this.id = id;
 }
 public String

Re: Unable to use wicket tester to simulate ajax behavior

2012-07-10 Thread Giovanni Cuccu

Hi,
can someone give me an hint on this?
I tried to explain my problem providing a complete example and 
explaining what I was trying to achieve.
I'd like to know if there is a specific reason of getting no answer so I 
can change something on my side the next time I need to write to the list.

Thanks,
Giovanni
Il 05/07/12 08.10, Giovanni Cuccu ha scritto:


Hi all,
I'm trying to test a wicket 1.5.7 application and I'm hitting a
strange (at least for me) issue.
I have two dropdowns (combo 1 and combo2) and when I select one value
from combo1 I fire an AjaxUpdateBehavior on onchange event which selects
a value on combo2.
If I use the application everything is working as expected but If I try
to simulate the application with wicket tester I come into trouble.
Basically the test code is the following one:

WicketTester tester= new WicketTester(new WicketApplication());
tester.startPage(TestAjaxDropDown.class);
FormTester formTester=tester.newFormTester(form);
formTester.select(combo1, 0);
tester.executeAjaxEvent(form:combo1, onchange);
formTester.submit();
tester.assertNoErrorMessage();

what I got is that after firing the onchange event combo1 gets a null
value as object model and this does not happen when I use a browser. If
I do not fire the event the application reports that combo2 has no
element selected.
Am I  missing something or is it a bug?

Grazie,
  Giovanni

P.S. I built a simple test case that I insert here

main page class

package com.sg2net.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.PropertyModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class TestAjaxDropDown extends WebPage {

private static final Logger
logger=LoggerFactory.getLogger(TestAjaxDropDown.class.getName());

public TestAjaxDropDown() {
add(new FeedbackPanel(feedback));
add(new TestAjaxDropDownFrom(form));
}

private class DomainObject1 implements Serializable {
public DomainObject1(long id, String description) {
super();
this.id = id;
this.description = description;
}
private static final long serialVersionUID = 1L;
private long id;
private String description;

public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType().hashCode();
result = prime * result + (int) (id ^ (id  32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DomainObject1 other = (DomainObject1) obj;
if (!getOuterType().equals(other.getOuterType()))
return false;
if (id != other.id)
return false;
return true;
}
private TestAjaxDropDown getOuterType() {
return TestAjaxDropDown.this;
}

}

private class DomainObject2 implements Serializable {
public DomainObject2(long id, String description) {
super();
this.id = id;
this.description = description;
}
private static final long serialVersionUID = 1L;
private long id;
private String description;

public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType().hashCode();
result = prime * result + (int) (id ^ (id  32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj

Re: image from outside web application directory

2012-07-05 Thread Giovanni Cuccu

Hi,
   it's not wicket related but if you are using tomcat as application 
server you can use the aliases attribute of the context ( 
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html) which 
allows you to map an external (to your web app) dir to an url (es 
c:/images on filesystem as /images in the url)

ciao,
 Giovanni

Il 05/07/12 00.49, lang ha scritto:

I need to show images from c:/pictures on my website. I searched and searched
and there should be something on old.nabble  but that link is giving null
pointer results. Who can help?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/image-from-outside-web-application-directory-tp4650379.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





--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it





Unable to use wicket tester to simulate ajax behavior

2012-07-05 Thread Giovanni Cuccu
;
return true;
}
private TestAjaxDropDown getOuterType() {
return TestAjaxDropDown.this;
}

}

private static final long serialVersionUID = 1L;

private class TestAjaxDropDownFrom extends FormVoid {

private static final long serialVersionUID = 1L;
private DomainObject1 domainObject1;
private DomainObject2 domainObject2;
private DropDownChoiceDomainObject2 secondCombo;

public TestAjaxDropDownFrom(String id) {
super(id);
ListDomainObject1 choicesForCombo1= new
ArrayListDomainObject1();
choicesForCombo1.add(new DomainObject1(1L,uno));
choicesForCombo1.add(new DomainObject1(2L,due));
choicesForCombo1.add(new DomainObject1(3L,tre));
DropDownChoiceDomainObject1 firstCombo= new
DropDownChoiceDomainObject1(combo1,
new
PropertyModelDomainObject1(this,domainObject1),choicesForCombo1,
new ChoiceRendererDomainObject1(description,
id));
firstCombo.setRequired(true);
firstCombo.setNullValid(true);
firstCombo.add(new AjaxUpdateBehavior(onchange));
add(firstCombo);

ListDomainObject2 choicesForCombo2= new
ArrayListDomainObject2();
choicesForCombo2.add(new DomainObject2(10L,unozero));
choicesForCombo2.add(new DomainObject2(20L,duezero));
choicesForCombo2.add(new DomainObject2(30L,trezero));
secondCombo= new DropDownChoiceDomainObject2(combo2,
new
PropertyModelDomainObject2(this,domainObject2),choicesForCombo2,
new ChoiceRendererDomainObject2(description,
id));
secondCombo.setOutputMarkupId(true);
secondCombo.setNullValid(true);
add(secondCombo);

}

@Override
public void onSubmit() {
if (domainObject2==null) {
error(Domain object2 is null);
} else {
info(OK);
}
}

private class AjaxUpdateBehavior extends
AjaxFormComponentUpdatingBehavior {


private static final long serialVersionUID = 1L;

public AjaxUpdateBehavior(String event) {
super(event);
}

@Override
protected void onUpdate(AjaxRequestTarget target) {
if (domainObject1!=null) {
logger.warn(domainObject1.getId()= +
domainObject1.getId());
if (domainObject1.getId()==1L) {
domainObject2=new DomainObject2(10L,unozero);
logger.warn(domainObject2.getId()= +
domainObject2.getId());
}
if (domainObject1.getId()==2L) {
domainObject2=new DomainObject2(20L,duezero);
logger.warn(domainObject2.getId()= +
domainObject2.getId());
}
if (domainObject1.getId()==3L) {
domainObject2=new DomainObject2(30L,trezero);
logger.warn(domainObject2.getId()= +
domainObject2.getId());
}
secondCombo.modelChanged();
target.add(secondCombo);
} else {
logger.warn(domainObject1==null);
}
}
}

}
}

test class

package com.sg2net.test;

import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.Test;

public class WicketTesterAjaxDropDown {
@Test
public void testAjaxDropDown() {
WicketTester tester= new WicketTester(new WicketApplication());
tester.startPage(TestAjaxDropDown.class);
FormTester formTester=tester.newFormTester(form);
formTester.select(combo1, 0);
tester.executeAjaxEvent(form:combo1, onchange);
//formTester.select(combo1, 0);
formTester.submit();
tester.assertNoErrorMessage();
}
}

wicket application class

package com.sg2net.test;
import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;

import com.sg2net.test.TestAjaxDropDown;


public class WicketApplication extends WebApplication {

@Override
public Class? extends Page getHomePage() {

return TestAjaxDropDown.class;
}

protected void init() {
getMarkupSettings().setDefaultMarkupEncoding(UTF-8);
}

}



--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it




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



Possibile bug in MockHttpServletRequest

2012-01-30 Thread Giovanni Cuccu

Hello,
I'm starting to user WicketTester and I've hit the following behaviour.
I have a IRequestCycleListener wich needs to access to the httpSession. 
In my code I was using

HttpSession httpSession=httpRequest.getSession();
which works fine within the real servlet  container (i.e. tomcat) but 
fails when I use WicketTester

In order to make wicketteset work I had to change the previous line to:
HttpSession httpSession=httpRequest.getSession(true);
But if I look at the servler api specs 
(http://docs.oracle.com/javaee/1.4/api/) the api says:


public HttpSession getSession()
Returns the current session associated with this request, or if the 
request does not have a session, creates one.


So as far as I understand
httpRequest.getSession(); and httpRequest.getSession(true); are equivalent

If my assumption is correct the MockHttpServletRequest implementation is 
incorrect since it returns null in my case.

The code in the mock class is the following one
public HttpSession getSession()
{
if (session instanceof MockHttpSession  
((MockHttpSession)session).isTemporary())

{
return null;
}
return session;
}
Is it a bug or am I missing something?
ciao,
Giovanni


--
Giovanni Cuccu
CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: Possibile bug in MockHttpServletRequest

2012-01-30 Thread Giovanni Cuccu

Hi Martin,
done.
https://issues.apache.org/jira/browse/WICKET-4370
ciao,
Giovanni


In
  my code I was using
  HttpSession httpSession=httpRequest.getSession();
  which works fine within the real servlet  container (i.e. tomcat) but fails
  when I use WicketTester
  In order to make wicketteset work I had to change the previous line to:
  HttpSession httpSession=httpRequest.getSession(true);
  But if I look at the servler api specs
  (http://docs.oracle.com/javaee/1.4/api/) the api says:

  public HttpSession getSession()
  Returns the current session associated with this request, or if the request
  does not have a session, creates one.

  So as far as I understand
  httpRequest.getSession(); and httpRequest.getSession(true); are equivalent

  If my assumption is correct the MockHttpServletRequest implementation is
  incorrect since it returns null in my case.
  The code in the mock class is the following one
  public HttpSession getSession()
  {
  if (session instanceof MockHttpSession
  ((MockHttpSession)session).isTemporary())
  {
  return null;
  }
  return session;
  }



--
Giovanni Cuccu
CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



TextField with error css and errorMessage

2011-02-22 Thread Giovanni Cuccu

Hi,
I've written a TextField component that starts (by subclassing) 
from TextField and when the component is not valid it adds a custom css 
and it appends the error description near the field.
The goal was to create a replacement for TextField leaving the html as 
it was before the subclassed TextField usage (i.e. the only required 
change is the the class name in the java code)
I've implementend the component with two behaviours and the core lies in 
the onBeforeRender method.
I'm wondering if there are better approaches to achive the result; here 
is the method implementation:

@Override
public void onBeforeRender() {
if (!isValid()) {
add(cssErrorAppender);
add(errorMessageBehaviour);
final String error;
String preMessage=prefix + + errorDescriptionTag + 
class=\+ errorDescriptionClass + \;

String postMessage=/+ errorDescriptionTag + ;
if (hasFeedbackMessage()) {
error = preMessage 
+getFeedbackMessage().getMessage().toString()+ postMessage;

} else {
error = preMessage +getString(input.invalid) +  
postMessage;

}
errorMessageBehaviour.setErrorDescription(error);
addedBehaviour=true;
} else {
if (addedBehaviour) {
remove(cssErrorAppender);
remove(errorMessageBehaviour);
addedBehaviour=false;
}
}
super.onBeforeRender();
}

here is the declaration of behaviour

private AttributeAppender cssErrorAppender=new 
AttributeAppender(class, new ModelString(errorClass),  );
private ErrorMessageBehaviour errorMessageBehaviour=new 
ErrorMessageBehaviour();


Thanks,
   Giovanni

--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: FileUploadField within RepeatingView

2010-04-27 Thread Giovanni Cuccu

Hi,
	please ignore my previous request. I'm investigating the issue and the 
cause seems related to a bug in my code. The bug is still here but this 
is another issue.

Regards,
Giovanni

Hi,
I'm trying to build a form with multiple file upload fields. Each 
upload field has a companion text field used for describing the file 
content.

I'm using a form with a RepeatingView:
here is a simple code snippet:
private FileUpload upload0;
private FileUpload upload1;


RepeatingView allegatiView = new RepeatingView(allegati);
add(allegatiView);
int i=0;
for(SegnalazioneAllegato segnalazioneAllegato: allegati) {
WebMarkupContainer allegatoContainer= new 
WebMarkupContainer(allegatiView.newChildId());

allegatiView.add(allegatoContainer);
allegatoContainer.add(new TextFieldString(descrizione,new 
PropertyModelString(segnalazioneAllegato,descrizioneAllegato)));
allegatoContainer.add(new FileUploadField(allegato,new 
PropertyModelFileUpload(this,upload+ i +)));

}
If I configure only one FileUploadField the fileupload succeds while if 
I use two FileUploadField instances I can't get the data because upload0 
and upload1 are both null.
I can't use MultiFileUploadField because each file must be submitted 
along with a description.

Is this a bug or am I missing something?
Is it possible to use multiple MultiFileUploadField instances witihin a 
form?

Thanks a lot,
Giovanni





--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



FileUploadField within RepeatingView

2010-04-26 Thread Giovanni Cuccu

Hi,
	I'm trying to build a form with multiple file upload fields. Each 
upload field has a companion text field used for describing the file 
content.

I'm using a form with a RepeatingView:
here is a simple code snippet:
private FileUpload upload0;
private FileUpload upload1;


RepeatingView allegatiView = new RepeatingView(allegati);
add(allegatiView);
int i=0;
for(SegnalazioneAllegato segnalazioneAllegato: allegati) {
		WebMarkupContainer allegatoContainer= new 
WebMarkupContainer(allegatiView.newChildId());

allegatiView.add(allegatoContainer);
		allegatoContainer.add(new TextFieldString(descrizione,new 
PropertyModelString(segnalazioneAllegato,descrizioneAllegato)));
allegatoContainer.add(new FileUploadField(allegato,new 
PropertyModelFileUpload(this,upload+ i +)));

}
If I configure only one FileUploadField the fileupload succeds while if 
I use two FileUploadField instances I can't get the data because upload0 
and upload1 are both null.
I can't use MultiFileUploadField because each file must be submitted 
along with a description.

Is this a bug or am I missing something?
Is it possible to use multiple MultiFileUploadField instances witihin a 
form?

Thanks a lot,
Giovanni


--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: Best way to handle circular references

2009-09-25 Thread Giovanni Cuccu
I have no problem other than i dont like it, but since I don't like it 
I'd like to know if someone else had the same thoughts I had and what 
was the conclusion.

Giovanni


what is the actual problem you are having with this other then i dont like it?

-igor

On Wed, Sep 23, 2009 at 3:21 AM, Giovanni Cuccu
giovanni.cu...@cup2000.it wrote:

Hi all,
   I'm developing a wicket application and I'm facing a problem.
I built a menupanel that shows the menu to access the various aplication
pages; since the panel needs to show the pages it contains a list of links
that when clicked simply do the the following
   setResponsePage(new Page());
In the class menupanel.java I must reference Page
In the class Page.java I must reference MenuPanel
At the end I have a circular reference between manupanel and the various
Page and I don't like it.
While reading wicketInAction I noted that in the examples there is a
circular reference between Checkout page and Index page. Are circular
references unavoidable with Wicket? Is there a best practive to avoid this
situation?
Thanks,
   Giovanni


--
Giovanni Cuccu
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


-
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






--
Giovanni Cuccu
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Best way to handle circular references

2009-09-23 Thread Giovanni Cuccu

Hi all,
I'm developing a wicket application and I'm facing a problem.
I built a menupanel that shows the menu to access the various aplication 
pages; since the panel needs to show the pages it contains a list of 
links that when clicked simply do the the following

setResponsePage(new Page());
In the class menupanel.java I must reference Page
In the class Page.java I must reference MenuPanel
At the end I have a circular reference between manupanel and the various 
Page and I don't like it.
While reading wicketInAction I noted that in the examples there is a 
circular reference between Checkout page and Index page. Are circular 
references unavoidable with Wicket? Is there a best practive to avoid 
this situation?

Thanks,
Giovanni


--
Giovanni Cuccu
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: Best way to handle circular references

2009-09-23 Thread Giovanni Cuccu

Thanks for the response,
I try to clarify my point of view.
Before using wicket I don't remember that my classes were cross 
references, I always paid attention that if class A references Class B 
Class B can't reference Class A (even in imports).
After starting wicket development I've seen several cases of circular 
references in my code. Since these circular references sometimes seem 
natural (Page references MenuPanel and MenuPanel references Page) but at 
the same time I consider the a bad practice I'm asking to myself and 
to this list if someone had the same thoughts and what was the conclusion.

What is your advice?
Should I relax my best practice about class circular referencing? 
Should I code my Wicket app in a different manner?

Thanks,
Giovanni


It looks like you are looking for cohesion.
In the class menupanel.java I must reference Page
In the class Page.java I must reference MenuPanel

menupanel can to be an parameter to PageXXX; PageXXX can to be abstract and
have an abstract method :
abstract protected Page
getPageToSetOnReturnOnCase1Case2And3(PossibleParameter p);

noted that in the examples there is a circular reference between Checkout
page and Index page
on the example the objects has an reference to the other type class. And the
class object do not has an reference those objects. I don't see it as
circular reference.

Are circular references unavoidable with Wicket?
do they are unavoidable in java, in object oriented paradigm? Is this the
correct question?

Is there a best practive to avoid this situation?
When I avoid an circular reference, I make a choice between a several
possible solutions, the on I get depends on the class objectives


On Wed, Sep 23, 2009 at 7:21 AM, Giovanni Cuccu
giovanni.cu...@cup2000.itwrote:


Hi all,
   I'm developing a wicket application and I'm facing a problem.
I built a menupanel that shows the menu to access the various aplication
pages; since the panel needs to show the pages it contains a list of links
that when clicked simply do the the following
   setResponsePage(new Page());
In the class menupanel.java I must reference Page
In the class Page.java I must reference MenuPanel
At the end I have a circular reference between manupanel and the various
Page and I don't like it.
While reading wicketInAction I noted that in the examples there is a
circular reference between Checkout page and Index page. Are circular
references unavoidable with Wicket? Is there a best practive to avoid this
situation?
Thanks,
   Giovanni


--
Giovanni Cuccu
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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







--
Giovanni Cuccu
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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