Re: wiquery ResizableBehavior weird results on stop

2013-03-11 Thread Pieter Claassen
Ernesto,

This is very strange. When I use your snapshot code in a quickstart
project, it functions fine. But when I include it in my project, I always
get the old x and y values (of one resize ago) in my callback.

Can you think of any reason why this would be happening? Could this be an
issue with the javascript code? I see my wicket ajax debug window does not
show my function parameters being used in the call so I can't see if it is
JS or wicket issue. How do I start to debug this?

Regards,
Pieter

On Sun, Mar 10, 2013 at 10:02 AM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 Pieter,

 Can you create a quickstart or something I can give it a try? Or give it
 a try to what I have added to wiquery: test panel I have created there
 seems to be working fine. If those changes work fine for you I can as other
 team member to roll out a new version of wiquery next week;-)

 On Sun, Mar 10, 2013 at 8:56 AM, Pieter Claassen pie...@musmato.com
 wrote:

  Ernesto,
 
  Ok, I implemented your changes but something very strange is happening.
 In
  my callback, I get the resizeHeight and resizeWidth values of the
 previous
  window resize event, not the current one.
 
  I don't really know how to debug this other than drag the window smaller
  and larger and checking whether the values increase or decrease.
 
  Any suggestion for how to debug this?
 
  Regards,
  Pieter
 
 
 
  On Sat, Mar 9, 2013 at 4:56 PM, Ernesto Reinaldo Barreiro 
  reier...@gmail.com wrote:
 
   Pieter,
  
   I have just fixed wiquery to support the stop event. See commit
  
  
  
 
 https://github.com/WiQuery/wiquery/commit/c2e8242c9d1aba9ae64f7c67654e0e6539d36b78
  
   On problem there is that parameter coming form client are float
 values. I
   have added a test panel and ResizableStopAjaxBehavior seems to be
 working
   as expected.
  
   Hope this helps.
  
   Cheers.
  
   Ernesto
  
  
   On Sat, Mar 9, 2013 at 2:55 PM, Pieter Claassen pie...@musmato.com
   wrote:
  
I am still only interested in getting the size of a component on
 resize
stop.
   
Below is my code that I use to try and implement a call back to only
  call
on stop. However, the x and y sizes I get are all over the place.
 Not
   at
all corresponding with the window sizes I actually see when
  resizing.
   
I am using wiquery 6.2.0 and wicket 6.5.0.
   
Any advice as to what I am doing wrong?
   
Regards,
Pieter
   
MyResizableBehavior resizableBehavior = new
   MyResizableBehavior();
resizableBehavior.setStopEvent(new
MyResizableBehavior.AjaxResizeStopCallback() {
@Override
protected void resize(AjaxRequestTarget target, Component
source, int resizeHeight, int resizeWidth) {
AdvancedFormatter advancedFormatter =
questionBaseWebModel.getEntity().getStatement().getFormatter();
advancedFormatter.setWidth((float) resizeWidth / 800
 *
100);
advancedFormatter.setHeight((float) resizeHeight);
System.out.println(Width:+resizeWidth+
Height:+resizeHeight);
advancedFormatterFactory.save(advancedFormatter);
}
   
});
   
resizableBehavior.setAutoHide(true).setGhost(true).setAnimate(true);
resizableBehavior.setGrid(50, 50);
   

   
public class MyResizableBehavior extends ResizableBehavior {
public abstract static class AjaxResizeStopCallback extends
AbstractAjaxEventCallback
{
private static final long serialVersionUID = 1L;
   
public AjaxResizeStopCallback()
{
super(stop);
}
   
@Override
protected ListCallbackParameter getExtraParameters()
{
ListCallbackParameter ret = super.getExtraParameters();
ret.add(CallbackParameter.resolved(resizeHeight,
ResizableBehavior.UI_SIZE
+ .height));
ret.add(CallbackParameter.resolved(resizeWidth,
ResizableBehavior.UI_SIZE + .width));
return ret;
}
   
@Override
public final void call(AjaxRequestTarget target, Component
   source)
{
IRequestParameters req =
RequestCycle.get().getRequest().getRequestParameters();
   
int resizeHeight =
req.getParameterValue(resizeHeight).toInt(-1);
int resizeWidth =
req.getParameterValue(resizeWidth).toInt(-1);
resize(target, source, resizeHeight, resizeWidth);
}
   
protected abstract void resize(AjaxRequestTarget target,
   Component
source,
   int resizeHeight, int
   resizeWidth);
}
   
   
public MyResizableBehavior
setStopEvent(MyResizableBehavior.AjaxResizeStopCallback callback){
   
setEventListener

Re: wiquery ResizableBehavior weird results on stop

2013-03-11 Thread Pieter Claassen
Ok, I can confirm that the request URI contains the wrong (old parameters).
Below is a request URI I get after resizing the window to max width (note
the width here is 4px while the real panel is 800px).

Could this be that I have some dud JS floating around that is messing this
up?

wicket/page?140-1.IBehaviorListener.1-templateeditdetailpanel-questionrenderpanel-container-rows-0-row-0-question-holdereventName=stopresizeHeight=29resizeWidth=4_=1363018206108

This is what I have loaded ito ajax libraries in my header.

[image: Inline image 1]

Regards,
Pieter

On Mon, Mar 11, 2013 at 5:34 PM, Pieter Claassen pie...@musmato.com wrote:

 Ernesto,

 This is very strange. When I use your snapshot code in a quickstart
 project, it functions fine. But when I include it in my project, I always
 get the old x and y values (of one resize ago) in my callback.

 Can you think of any reason why this would be happening? Could this be an
 issue with the javascript code? I see my wicket ajax debug window does not
 show my function parameters being used in the call so I can't see if it is
 JS or wicket issue. How do I start to debug this?

 Regards,
 Pieter


 On Sun, Mar 10, 2013 at 10:02 AM, Ernesto Reinaldo Barreiro 
 reier...@gmail.com wrote:

 Pieter,

 Can you create a quickstart or something I can give it a try? Or give it
 a try to what I have added to wiquery: test panel I have created there
 seems to be working fine. If those changes work fine for you I can as
 other
 team member to roll out a new version of wiquery next week;-)

 On Sun, Mar 10, 2013 at 8:56 AM, Pieter Claassen pie...@musmato.com
 wrote:

  Ernesto,
 
  Ok, I implemented your changes but something very strange is happening.
 In
  my callback, I get the resizeHeight and resizeWidth values of the
 previous
  window resize event, not the current one.
 
  I don't really know how to debug this other than drag the window smaller
  and larger and checking whether the values increase or decrease.
 
  Any suggestion for how to debug this?
 
  Regards,
  Pieter
 
 
 
  On Sat, Mar 9, 2013 at 4:56 PM, Ernesto Reinaldo Barreiro 
  reier...@gmail.com wrote:
 
   Pieter,
  
   I have just fixed wiquery to support the stop event. See commit
  
  
  
 
 https://github.com/WiQuery/wiquery/commit/c2e8242c9d1aba9ae64f7c67654e0e6539d36b78
  
   On problem there is that parameter coming form client are float
 values. I
   have added a test panel and ResizableStopAjaxBehavior seems to be
 working
   as expected.
  
   Hope this helps.
  
   Cheers.
  
   Ernesto
  
  
   On Sat, Mar 9, 2013 at 2:55 PM, Pieter Claassen pie...@musmato.com
   wrote:
  
I am still only interested in getting the size of a component on
 resize
stop.
   
Below is my code that I use to try and implement a call back to only
  call
on stop. However, the x and y sizes I get are all over the place.
 Not
   at
all corresponding with the window sizes I actually see when
  resizing.
   
I am using wiquery 6.2.0 and wicket 6.5.0.
   
Any advice as to what I am doing wrong?
   
Regards,
Pieter
   
MyResizableBehavior resizableBehavior = new
   MyResizableBehavior();
resizableBehavior.setStopEvent(new
MyResizableBehavior.AjaxResizeStopCallback() {
@Override
protected void resize(AjaxRequestTarget target,
 Component
source, int resizeHeight, int resizeWidth) {
AdvancedFormatter advancedFormatter =
questionBaseWebModel.getEntity().getStatement().getFormatter();
advancedFormatter.setWidth((float) resizeWidth /
 800 *
100);
advancedFormatter.setHeight((float) resizeHeight);
System.out.println(Width:+resizeWidth+
Height:+resizeHeight);
advancedFormatterFactory.save(advancedFormatter);
}
   
});
   
resizableBehavior.setAutoHide(true).setGhost(true).setAnimate(true);
resizableBehavior.setGrid(50, 50);
   

   
public class MyResizableBehavior extends ResizableBehavior {
public abstract static class AjaxResizeStopCallback extends
AbstractAjaxEventCallback
{
private static final long serialVersionUID = 1L;
   
public AjaxResizeStopCallback()
{
super(stop);
}
   
@Override
protected ListCallbackParameter getExtraParameters()
{
ListCallbackParameter ret =
 super.getExtraParameters();
ret.add(CallbackParameter.resolved(resizeHeight,
ResizableBehavior.UI_SIZE
+ .height));
ret.add(CallbackParameter.resolved(resizeWidth,
ResizableBehavior.UI_SIZE + .width));
return ret;
}
   
@Override
public final void call(AjaxRequestTarget target, Component
   source)
{
IRequestParameters

wiquery ResizableBehavior weird results on stop

2013-03-09 Thread Pieter Claassen
I am still only interested in getting the size of a component on resize
stop.

Below is my code that I use to try and implement a call back to only call
on stop. However, the x and y sizes I get are all over the place. Not at
all corresponding with the window sizes I actually see when  resizing.

I am using wiquery 6.2.0 and wicket 6.5.0.

Any advice as to what I am doing wrong?

Regards,
Pieter

MyResizableBehavior resizableBehavior = new MyResizableBehavior();
resizableBehavior.setStopEvent(new
MyResizableBehavior.AjaxResizeStopCallback() {
@Override
protected void resize(AjaxRequestTarget target, Component
source, int resizeHeight, int resizeWidth) {
AdvancedFormatter advancedFormatter =
questionBaseWebModel.getEntity().getStatement().getFormatter();
advancedFormatter.setWidth((float) resizeWidth / 800 * 100);
advancedFormatter.setHeight((float) resizeHeight);
System.out.println(Width:+resizeWidth+
Height:+resizeHeight);
advancedFormatterFactory.save(advancedFormatter);
}

});
resizableBehavior.setAutoHide(true).setGhost(true).setAnimate(true);
resizableBehavior.setGrid(50, 50);



public class MyResizableBehavior extends ResizableBehavior {
public abstract static class AjaxResizeStopCallback extends
AbstractAjaxEventCallback
{
private static final long serialVersionUID = 1L;

public AjaxResizeStopCallback()
{
super(stop);
}

@Override
protected ListCallbackParameter getExtraParameters()
{
ListCallbackParameter ret = super.getExtraParameters();
ret.add(CallbackParameter.resolved(resizeHeight,
ResizableBehavior.UI_SIZE
+ .height));
ret.add(CallbackParameter.resolved(resizeWidth,
ResizableBehavior.UI_SIZE + .width));
return ret;
}

@Override
public final void call(AjaxRequestTarget target, Component source)
{
IRequestParameters req =
RequestCycle.get().getRequest().getRequestParameters();

int resizeHeight =
req.getParameterValue(resizeHeight).toInt(-1);
int resizeWidth =
req.getParameterValue(resizeWidth).toInt(-1);
resize(target, source, resizeHeight, resizeWidth);
}

protected abstract void resize(AjaxRequestTarget target, Component
source,
   int resizeHeight, int resizeWidth);
}


public MyResizableBehavior
setStopEvent(MyResizableBehavior.AjaxResizeStopCallback callback){

setEventListener(callback);
return this;
}
}



-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t NL: +31 (20) 893 4337
  t ZA: + 27 (0) 81 826 8166
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


Re: wiquery ResizableBehavior weird results on stop

2013-03-09 Thread Pieter Claassen
Ernesto,

Ok, I implemented your changes but something very strange is happening. In
my callback, I get the resizeHeight and resizeWidth values of the previous
window resize event, not the current one.

I don't really know how to debug this other than drag the window smaller
and larger and checking whether the values increase or decrease.

Any suggestion for how to debug this?

Regards,
Pieter



On Sat, Mar 9, 2013 at 4:56 PM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 Pieter,

 I have just fixed wiquery to support the stop event. See commit


 https://github.com/WiQuery/wiquery/commit/c2e8242c9d1aba9ae64f7c67654e0e6539d36b78

 On problem there is that parameter coming form client are float values. I
 have added a test panel and ResizableStopAjaxBehavior seems to be working
 as expected.

 Hope this helps.

 Cheers.

 Ernesto


 On Sat, Mar 9, 2013 at 2:55 PM, Pieter Claassen pie...@musmato.com
 wrote:

  I am still only interested in getting the size of a component on resize
  stop.
 
  Below is my code that I use to try and implement a call back to only call
  on stop. However, the x and y sizes I get are all over the place. Not
 at
  all corresponding with the window sizes I actually see when  resizing.
 
  I am using wiquery 6.2.0 and wicket 6.5.0.
 
  Any advice as to what I am doing wrong?
 
  Regards,
  Pieter
 
  MyResizableBehavior resizableBehavior = new
 MyResizableBehavior();
  resizableBehavior.setStopEvent(new
  MyResizableBehavior.AjaxResizeStopCallback() {
  @Override
  protected void resize(AjaxRequestTarget target, Component
  source, int resizeHeight, int resizeWidth) {
  AdvancedFormatter advancedFormatter =
  questionBaseWebModel.getEntity().getStatement().getFormatter();
  advancedFormatter.setWidth((float) resizeWidth / 800 *
  100);
  advancedFormatter.setHeight((float) resizeHeight);
  System.out.println(Width:+resizeWidth+
  Height:+resizeHeight);
  advancedFormatterFactory.save(advancedFormatter);
  }
 
  });
 
  resizableBehavior.setAutoHide(true).setGhost(true).setAnimate(true);
  resizableBehavior.setGrid(50, 50);
 
  
 
  public class MyResizableBehavior extends ResizableBehavior {
  public abstract static class AjaxResizeStopCallback extends
  AbstractAjaxEventCallback
  {
  private static final long serialVersionUID = 1L;
 
  public AjaxResizeStopCallback()
  {
  super(stop);
  }
 
  @Override
  protected ListCallbackParameter getExtraParameters()
  {
  ListCallbackParameter ret = super.getExtraParameters();
  ret.add(CallbackParameter.resolved(resizeHeight,
  ResizableBehavior.UI_SIZE
  + .height));
  ret.add(CallbackParameter.resolved(resizeWidth,
  ResizableBehavior.UI_SIZE + .width));
  return ret;
  }
 
  @Override
  public final void call(AjaxRequestTarget target, Component
 source)
  {
  IRequestParameters req =
  RequestCycle.get().getRequest().getRequestParameters();
 
  int resizeHeight =
  req.getParameterValue(resizeHeight).toInt(-1);
  int resizeWidth =
  req.getParameterValue(resizeWidth).toInt(-1);
  resize(target, source, resizeHeight, resizeWidth);
  }
 
  protected abstract void resize(AjaxRequestTarget target,
 Component
  source,
 int resizeHeight, int
 resizeWidth);
  }
 
 
  public MyResizableBehavior
  setStopEvent(MyResizableBehavior.AjaxResizeStopCallback callback){
 
  setEventListener(callback);
  return this;
  }
  }
 
 
 
  --
  - - - - - - - - - - - - - - - - - - - -
Pieter Claassen
Musmato B.V.
e: pieter.claas...@musmato.com
t NL: +31 (20) 893 4337
t ZA: + 27 (0) 81 826 8166
w: http://musmato.com
  - - - - - - - - - - - - - - - - - - - -
 



 --
 Regards - Ernesto Reinaldo Barreiro
 Antilia Soft
 http://antiliasoft.com/ http://antiliasoft.com/antilia




-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t NL: +31 (20) 893 4337
  t ZA: + 27 (0) 81 826 8166
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


Re: JQuery - best practice

2013-01-30 Thread Pieter Claassen
Ernesto/Sebastien,

I am stuck :-(

Firstly, thanks for the resizablePanel in wicket-jquery-ui, but I have to
hold off until this code is implemented in a behavior since my inheritance
doesn't match your project (I cannot inherit from resizablePanel).

I looked at what was available in wiquery and found the functionality
there, except.

When I implement the code below, I force an ajax round-trip to the service
whenever the re-size event is triggered which is a lot during a
panel re-size  This is not practical with the the model updates. Ideally
one would like to only update the position on stopEvents but the API
provides only for the setting of a JavaScript callback on stopEvents.

Does anybody have a suggestion on how to make this behavior practically
usable?

Thanks,
Pieter


 ResizableBehavior resizableBehavior = new ResizableBehavior();
resizableBehavior.setResizeEvent(new
ResizableBehavior.AjaxResizeCallback() {
@Override
protected void resize(AjaxRequestTarget target, Component
source, int resizeHeight, int resizeWidth) {
AdvancedFormatter advancedFormatter =
questionBaseWebModel.getEntity().getStatement().getFormatter();
advancedFormatter.setWidth((float)resizeWidth / 800 * 100);
advancedFormatter.setHeight((float)resizeHeight);
advancedFormatterFactory.save(advancedFormatter);
}

});

This is available but only for JavaScript callbacks

 resizableBehavior.setStopEvent(JsScopeUiEvent.quickScope(alert();));





On Mon, Jan 28, 2013 at 8:28 AM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 Hi,

 On Mon, Jan 28, 2013 at 7:45 AM, Pieter Claassen pie...@musmato.com
 wrote:

  This is a general best practice question. I am using wicket-jquery-ui
  because I don't seem to be able to find a resizable panel in the
  internal wicket ajax widgets.
 
  1. Is there no problem loading new jquery libraries over the wicket
  implementation? What is best practice?
 

 Look at the existing jquery integrations and see what people do?



  2. I am looking for a way to get the resized panels' x and y size
  parameters into my wicket code? Any suggestions how to do this?
 
  You have to:

 1-Hook onto the client side events triggered by resize and use
 Wicket.AJA.get/post to stream back the parameters.
 2-Attach and AJAX behavior at server side component and on respond get and
 parse those parameter.

 Examples?


 https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/slider/AjaxSlider.java

 https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/tabs/Tabs.java

 or event better


 https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/resizable/ResizableBehavior.java

 wihc already have that functionality (see AjaxResizeCallback)



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


 --
 Regards - Ernesto Reinaldo Barreiro
 Antilia Soft
 http://antiliasoft.com/ http://antiliasoft.com/antilia




-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t: +31 877 848259
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


Re: JQuery - best practice

2013-01-30 Thread Pieter Claassen
Ernesto,

I cannot find any code in wiquery-6.2.0. that hooks into the stopEvent. The
example you provided seems to still force a round trip on any change, not
just on stopEvent.

Maybe I am daft, but I don't see any code that does this? I assume one can
extend ResizableBehaviour and add the stopEvent code to hook into a
callback, but I don't want to do this if this functionality already exists
and I just can't find it.

Thanks for the help.
Pieter


On Wed, Jan 30, 2013 at 3:00 PM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 Pieter,

 Look at this example.


 http://antiliasoft.com/wiquery-plugins/?wicket:bookmarkablePage=:com.wiquery.plugins.demo.ResizablePage

 and click on the ? at the left corner/. It is exactly what you want...
 Wiquery  already have a ResizableAjaxBehavior that hooks into stopEvent.
 Fell free to copy or adapt it to your needs;-). Let me know if I can
 further help you somehow.

 On Wed, Jan 30, 2013 at 2:46 PM, Pieter Claassen pie...@musmato.com
 wrote:

  Ernesto/Sebastien,
 
  I am stuck :-(
 
  Firstly, thanks for the resizablePanel in wicket-jquery-ui, but I have to
  hold off until this code is implemented in a behavior since my
 inheritance
  doesn't match your project (I cannot inherit from resizablePanel).
 
  I looked at what was available in wiquery and found the functionality
  there, except.
 
  When I implement the code below, I force an ajax round-trip to the
 service
  whenever the re-size event is triggered which is a lot during a
  panel re-size  This is not practical with the the model updates. Ideally
  one would like to only update the position on stopEvents but the API
  provides only for the setting of a JavaScript callback on stopEvents.
 
  Does anybody have a suggestion on how to make this behavior practically
  usable?
 
  Thanks,
  Pieter
 
 
   ResizableBehavior resizableBehavior = new ResizableBehavior();
  resizableBehavior.setResizeEvent(new
  ResizableBehavior.AjaxResizeCallback() {
  @Override
  protected void resize(AjaxRequestTarget target, Component
  source, int resizeHeight, int resizeWidth) {
  AdvancedFormatter advancedFormatter =
  questionBaseWebModel.getEntity().getStatement().getFormatter();
  advancedFormatter.setWidth((float)resizeWidth / 800 *
 100);
  advancedFormatter.setHeight((float)resizeHeight);
  advancedFormatterFactory.save(advancedFormatter);
  }
 
  });
 
  This is available but only for JavaScript callbacks
 
   resizableBehavior.setStopEvent(JsScopeUiEvent.quickScope(alert();));
 
 
 
 
 
  On Mon, Jan 28, 2013 at 8:28 AM, Ernesto Reinaldo Barreiro 
  reier...@gmail.com wrote:
 
   Hi,
  
   On Mon, Jan 28, 2013 at 7:45 AM, Pieter Claassen pie...@musmato.com
   wrote:
  
This is a general best practice question. I am using wicket-jquery-ui
because I don't seem to be able to find a resizable panel in the
internal wicket ajax widgets.
   
1. Is there no problem loading new jquery libraries over the wicket
implementation? What is best practice?
   
  
   Look at the existing jquery integrations and see what people do?
  
  
  
2. I am looking for a way to get the resized panels' x and y size
parameters into my wicket code? Any suggestions how to do this?
   
You have to:
  
   1-Hook onto the client side events triggered by resize and use
   Wicket.AJA.get/post to stream back the parameters.
   2-Attach and AJAX behavior at server side component and on respond get
  and
   parse those parameter.
  
   Examples?
  
  
  
 
 https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/slider/AjaxSlider.java
  
  
 
 https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/tabs/Tabs.java
  
   or event better
  
  
  
 
 https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/resizable/ResizableBehavior.java
  
   wihc already have that functionality (see AjaxResizeCallback)
  
  
  
Thanks,
Pieter
   
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
   
   
  
  
   --
   Regards - Ernesto Reinaldo Barreiro
   Antilia Soft
   http://antiliasoft.com/ http://antiliasoft.com/antilia
  
 
 
 
  --
  - - - - - - - - - - - - - - - - - - - -
Pieter Claassen
Musmato B.V.
e: pieter.claas...@musmato.com
t: +31 877 848259
w: http://musmato.com
  - - - - - - - - - - - - - - - - - - - -
 



 --
 Regards - Ernesto Reinaldo Barreiro
 Antilia Soft
 http://antiliasoft.com/ http://antiliasoft.com/antilia




-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t: +31 877 848259
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


Re: JQuery - best practice

2013-01-30 Thread Pieter Claassen
Ok, I just implemented my own. Seems to work.

In my code
MyResizableBehavior resizableBehavior = new MyResizableBehavior();
resizableBehavior.setStopEvent(new
MyResizableBehavior.AjaxResizeStopCallback() {
@Override
protected void resize(AjaxRequestTarget target, Component
source, int resizeHeight, int resizeWidth) {

}

});


public class MyResizableBehavior extends ResizableBehavior {
public abstract static class AjaxResizeStopCallback extends
AbstractAjaxEventCallback
{
private static final long serialVersionUID = 1L;

public AjaxResizeStopCallback()
{
super(stop);
}

@Override
protected ListCallbackParameter getExtraParameters()
{
ListCallbackParameter ret = super.getExtraParameters();
ret.add(CallbackParameter.resolved(resizeHeight,
ResizableBehavior.UI_SIZE
+ .height));
ret.add(CallbackParameter.resolved(resizeWidth,
ResizableBehavior.UI_SIZE + .width));
return ret;
}

@Override
public final void call(AjaxRequestTarget target, Component source)
{
IRequestParameters req =
RequestCycle.get().getRequest().getRequestParameters();

int resizeHeight =
req.getParameterValue(resizeHeight).toInt(-1);
int resizeWidth =
req.getParameterValue(resizeWidth).toInt(-1);
resize(target, source, resizeHeight, resizeWidth);
}

protected abstract void resize(AjaxRequestTarget target, Component
source,
   int resizeHeight, int resizeWidth);
}


public MyResizableBehavior
setStopEvent(MyResizableBehavior.AjaxResizeStopCallback callback){

setEventListener(callback);
return this;
}
}


On Wed, Jan 30, 2013 at 3:15 PM, Pieter Claassen pie...@musmato.com wrote:

 Ernesto,

 I cannot find any code in wiquery-6.2.0. that hooks into the stopEvent.
 The example you provided seems to still force a round trip on any change,
 not just on stopEvent.

 Maybe I am daft, but I don't see any code that does this? I assume one can
 extend ResizableBehaviour and add the stopEvent code to hook into a
 callback, but I don't want to do this if this functionality already exists
 and I just can't find it.

 Thanks for the help.
 Pieter


 On Wed, Jan 30, 2013 at 3:00 PM, Ernesto Reinaldo Barreiro 
 reier...@gmail.com wrote:

 Pieter,

 Look at this example.


 http://antiliasoft.com/wiquery-plugins/?wicket:bookmarkablePage=:com.wiquery.plugins.demo.ResizablePage

 and click on the ? at the left corner/. It is exactly what you want...
 Wiquery  already have a ResizableAjaxBehavior that hooks into stopEvent.
 Fell free to copy or adapt it to your needs;-). Let me know if I can
 further help you somehow.

 On Wed, Jan 30, 2013 at 2:46 PM, Pieter Claassen pie...@musmato.com
 wrote:

  Ernesto/Sebastien,
 
  I am stuck :-(
 
  Firstly, thanks for the resizablePanel in wicket-jquery-ui, but I have
 to
  hold off until this code is implemented in a behavior since my
 inheritance
  doesn't match your project (I cannot inherit from resizablePanel).
 
  I looked at what was available in wiquery and found the functionality
  there, except.
 
  When I implement the code below, I force an ajax round-trip to the
 service
  whenever the re-size event is triggered which is a lot during a
  panel re-size  This is not practical with the the model updates. Ideally
  one would like to only update the position on stopEvents but the API
  provides only for the setting of a JavaScript callback on stopEvents.
 
  Does anybody have a suggestion on how to make this behavior practically
  usable?
 
  Thanks,
  Pieter
 
 
   ResizableBehavior resizableBehavior = new ResizableBehavior();
  resizableBehavior.setResizeEvent(new
  ResizableBehavior.AjaxResizeCallback() {
  @Override
  protected void resize(AjaxRequestTarget target, Component
  source, int resizeHeight, int resizeWidth) {
  AdvancedFormatter advancedFormatter =
  questionBaseWebModel.getEntity().getStatement().getFormatter();
  advancedFormatter.setWidth((float)resizeWidth / 800 *
 100);
  advancedFormatter.setHeight((float)resizeHeight);
  advancedFormatterFactory.save(advancedFormatter);
  }
 
  });
 
  This is available but only for JavaScript callbacks
 
   resizableBehavior.setStopEvent(JsScopeUiEvent.quickScope(alert();));
 
 
 
 
 
  On Mon, Jan 28, 2013 at 8:28 AM, Ernesto Reinaldo Barreiro 
  reier...@gmail.com wrote:
 
   Hi,
  
   On Mon, Jan 28, 2013 at 7:45 AM, Pieter Claassen pie...@musmato.com
   wrote:
  
This is a general best practice question. I am using
 wicket-jquery-ui
because I don't seem to be able to find a resizable panel in the
internal wicket ajax widgets.
   
1. Is there no problem loading

Re: JQuery - best practice

2013-01-28 Thread Pieter Claassen
Hi Sebastian,

Thanks. Wicket 6.5 is what I am using.

As to your question:

I am referring to the fact that Wicket documentation mentioned that JQuery
has been selected for the internal AJax implementation in Wicket. I take
that means that there is a JQuery JS library that ships with Wicket-core
and also wicket code that makes use of that library. If I now include my
own JQuery library and CSS, is there not a risk that both these libraries,
with mostly the same functions but potentially version skew, could be
loaded by the same page?

Also, I note that there are a number wicket-jquery projects out there. How
do they play together and not trample the internal Wicket implementation.

Regards,
Pieter



On Mon, Jan 28, 2013 at 10:18 AM, Sebastien seb...@gmail.com wrote:

 Hi Pieter

 I am not sure to undestand your first point. What libraries are you
 refering to? Internal wicket's library? A jQuery plugin? Another?

 About your second point, the ResizeBehavior does not currently implement
 the 'resize' event (which can retrieve size  position).
 To stay consistent with the current logic behind wicket-jquery-ui, I will
 do a ResizePanel which will support such event.
 That's not a big deal, I will look at this tonight...

 Are you using Wicket 1.5.x or 6.x?

 Thanks  best regards,
 Sebastien.

 On Mon, Jan 28, 2013 at 7:45 AM, Pieter Claassen pie...@musmato.com
 wrote:

  This is a general best practice question. I am using wicket-jquery-ui
  because I don't seem to be able to find a resizable panel in the
  internal wicket ajax widgets.
 
  1. Is there no problem loading new jquery libraries over the wicket
  implementation? What is best practice?
  2. I am looking for a way to get the resized panels' x and y size
  parameters into my wicket code? Any suggestions how to do this?
 
  Thanks,
  Pieter
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 




-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t: +31 877 848259
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


Re: JQuery - best practice

2013-01-28 Thread Pieter Claassen
Sebastien,

So by including the wicket-jquery-ui (if I follow the installation
instructions), does that not conflict with the jquery core library?

Regards,
Pieter

On Mon, Jan 28, 2013 at 11:38 AM, Sebastien seb...@gmail.com wrote:

 Hi Pieter,

 Yes, wicket is embedding jquery core library. If you include another jquery
 core well yes, you will probably get into troubles.

 If you really want to do that, you can specify your own jQuery core library
 version, in Wicket Application#init():

 IJavaScriptLibrarySettings settings = getJavaScriptLibrarySettings();
 settings.setJQueryReference(new MyJQueryReference());

 About conflicts with existing Wicket / jQuery UI implementation, that's the
 same, only one jQuery UI library version should be loaded at a time.
 In wicket-jquery-ui, you can change or remove the shipped library in the
 same way:

 IJQueryLibrarySettings settings = new JQueryLibrarySettings();

 settings.setJQueryReference(new MyJQueryReference()); // (jquery core, same
 code as above)
 settings.setJQueryUIReference(new
 JQueryPluginResourceReference(MyApplication.class,
 jquery-ui-x.x.x.min.js)); //new jquery ui version
 or
 settings.setJQueryUIReference(null) //removes jquery ui library

 this.setJavaScriptLibrarySettings(settings);

 Hope this helps,
 Sebastien.

 On Mon, Jan 28, 2013 at 10:31 AM, Pieter Claassen pie...@musmato.com
 wrote:

  Hi Sebastian,
 
  Thanks. Wicket 6.5 is what I am using.
 
  As to your question:
 
  I am referring to the fact that Wicket documentation mentioned that
 JQuery
  has been selected for the internal AJax implementation in Wicket. I take
  that means that there is a JQuery JS library that ships with Wicket-core
  and also wicket code that makes use of that library. If I now include my
  own JQuery library and CSS, is there not a risk that both these
 libraries,
  with mostly the same functions but potentially version skew, could be
  loaded by the same page?
 
  Also, I note that there are a number wicket-jquery projects out there.
 How
  do they play together and not trample the internal Wicket implementation.
 
  Regards,
  Pieter
 
 
 
  On Mon, Jan 28, 2013 at 10:18 AM, Sebastien seb...@gmail.com wrote:
 
   Hi Pieter
  
   I am not sure to undestand your first point. What libraries are you
   refering to? Internal wicket's library? A jQuery plugin? Another?
  
   About your second point, the ResizeBehavior does not currently
 implement
   the 'resize' event (which can retrieve size  position).
   To stay consistent with the current logic behind wicket-jquery-ui, I
 will
   do a ResizePanel which will support such event.
   That's not a big deal, I will look at this tonight...
  
   Are you using Wicket 1.5.x or 6.x?
  
   Thanks  best regards,
   Sebastien.
  
   On Mon, Jan 28, 2013 at 7:45 AM, Pieter Claassen pie...@musmato.com
   wrote:
  
This is a general best practice question. I am using wicket-jquery-ui
because I don't seem to be able to find a resizable panel in the
internal wicket ajax widgets.
   
1. Is there no problem loading new jquery libraries over the wicket
implementation? What is best practice?
2. I am looking for a way to get the resized panels' x and y size
parameters into my wicket code? Any suggestions how to do this?
   
Thanks,
Pieter
   
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
   
   
  
 
 
 
  --
  - - - - - - - - - - - - - - - - - - - -
Pieter Claassen
Musmato B.V.
e: pieter.claas...@musmato.com
t: +31 877 848259
w: http://musmato.com
  - - - - - - - - - - - - - - - - - - - -
 




-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t: +31 877 848259
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


ResizableBehavior multiple resizable panels on a page

2013-01-27 Thread Pieter Claassen
I have multiple panels on a page, each once constructed as follows:

* public EditableQuestionPanel(String id, final QuestionBaseWebModel
questionBaseWebModel, final TemplateWebModel templateWebModel, final
QuestionEditPanel panel) {*
*super(id);*
*Options options = new Options();*
*options.set(minWidth, 350);*
*options.set(minHeight, 85);*
*add(new ResizableBehavior(#resizable,options));*

Here is the HTML for each panel.

*wicket:panel*
*div id=resizable class=ui-widget-content*
*div class=question wicket:id=holder*
*a href=# wicket:id=editor*
*div id=label wicket:id=questionDisplayPanel*
*/div*
*/a*
* span wicket:id=navpanel/span*
*/div*
*/div*
*/wicket:panel*


I want them each to be resizable but only the first panel ever is.

I am using wicket-jquery-ui. Any idea what I am doing wrong here. Do I have
to give each pane a unique html id attribute?

Pieter


Re: ResizableBehavior multiple resizable panels on a page

2013-01-27 Thread Pieter Claassen
Thanks, that did the job.

Pieter

On Sun, Jan 27, 2013 at 5:35 PM, Sebastien seb...@gmail.com wrote:

 Hi Pieter,

 If you have multiple panel, they all have the same html-id (#resizable).
 (and so jquery statement $(#resizable) will only take the first one)

 What you need is to have different (rendered) html ids for each panels. So,
 you can simply do:
 add(new ResizableBehavior(# + this.setOutputMarkupId(true).getMarkupId(),
 options));

 Which can be shortened as:
 add(new ResizableBehavior(JQueryWidget.getSelector(this), options));

 Hope this helps,
 Sebastien.

 On Sun, Jan 27, 2013 at 5:19 PM, Pieter Claassen pie...@musmato.com
 wrote:

  I have multiple panels on a page, each once constructed as follows:
 
  * public EditableQuestionPanel(String id, final QuestionBaseWebModel
  questionBaseWebModel, final TemplateWebModel templateWebModel, final
  QuestionEditPanel panel) {*
  *super(id);*
  *Options options = new Options();*
  *options.set(minWidth, 350);*
  *options.set(minHeight, 85);*
  *add(new ResizableBehavior(#resizable,options));*
 
  Here is the HTML for each panel.
 
  *wicket:panel*
  *div id=resizable class=ui-widget-content*
  *div class=question wicket:id=holder*
  *a href=# wicket:id=editor*
  *div id=label wicket:id=questionDisplayPanel*
  */div*
  */a*
  * span wicket:id=navpanel/span*
  */div*
  */div*
  */wicket:panel*
 
 
  I want them each to be resizable but only the first panel ever is.
 
  I am using wicket-jquery-ui. Any idea what I am doing wrong here. Do I
 have
  to give each pane a unique html id attribute?
 
  Pieter
 




-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t: +31 877 848259
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


JQuery - best practice

2013-01-27 Thread Pieter Claassen
This is a general best practice question. I am using wicket-jquery-ui
because I don't seem to be able to find a resizable panel in the
internal wicket ajax widgets.

1. Is there no problem loading new jquery libraries over the wicket
implementation? What is best practice?
2. I am looking for a way to get the resized panels' x and y size
parameters into my wicket code? Any suggestions how to do this?

Thanks,
Pieter

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



Wicket 6.5 CompoundPropertyModel constructor ambiguity

2013-01-25 Thread Pieter Claassen
When I try to create the following model after migrating to wicket 6.5.0

new CompoundPropertyModelReportWebModel(reportWebModel)

*where*

ReportWebModel extends BaseWebModelReport

*and*

BaseWebModelT implements IModel

My IDE (Intellij) shows no problem with type checking the code but when I
try to compile it I get:

java: reference to CompoundPropertyModel is ambiguous, both constructor
CompoundPropertyModel(org.apache.wicket.model.IModelT) in
org.apache.wicket.model.CompoundPropertyModel and constructor
CompoundPropertyModel(T) in org.apache.wicket.model.CompoundPropertyModel
match

The problem goes away when I remove the generics but then I also lose the
type checking.

Any suggestions?

Thanks,
Pieter

-- 
- - - - - - - - - - - - - - - - - - - -
  Pieter Claassen
  Musmato B.V.
  e: pieter.claas...@musmato.com
  t: +31 877 848259
  w: http://musmato.com
- - - - - - - - - - - - - - - - - - - -


Listview and hibernate question: Objects don't get deleted before the listview getObject() is called

2010-06-25 Thread pieter claassen
I find that when I delete objects from my ListView, my model object for the
ListView still contains a reference to the object. When the view tries to
render, the object is already removed from the database and I get a null
response on my hibernate load(). I use opensessioninview and when I check my
logs, the delete statement comes way after the view was rendered.

It seems that ListView renders the new view before the transaction is closed
(but even then, the delete should be visible to later sql in the same
transaction).

Any ideas?
Regards,
Pieter



Log:

Hibernate: delete from ABSTRACTDATASET where ID=?


ListView:
===
ListView documents = new ListView(documents, new IModel() {

public Object getObject() {
return getDocumentList();
}




Re: Listview and hibernate question: Objects don't get deleted before the listview getObject() is called

2010-06-25 Thread pieter claassen
No, my DAO's inherit from HibernateDaoSupport and I just go with the
defaults.

Regards,
Pieter

On Fri, Jun 25, 2010 at 2:22 PM, James Carman ja...@carmanconsulting.comwrote:

 How are you managing transactions?

 On Fri, Jun 25, 2010 at 7:27 AM, pieter claassen
 pieter.claas...@gmail.com wrote:
  I find that when I delete objects from my ListView, my model object for
 the
  ListView still contains a reference to the object. When the view tries to
  render, the object is already removed from the database and I get a null
  response on my hibernate load(). I use opensessioninview and when I check
 my
  logs, the delete statement comes way after the view was rendered.
 
  It seems that ListView renders the new view before the transaction is
 closed
  (but even then, the delete should be visible to later sql in the same
  transaction).
 
  Any ideas?
  Regards,
  Pieter
 
 
 
  Log:
  
  Hibernate: delete from ABSTRACTDATASET where ID=?
 
 
  ListView:
  ===
 ListView documents = new ListView(documents, new IModel() {
 
 public Object getObject() {
 return getDocumentList();
 }
 
  
 




-- 
Pieter Claassen
musmato.com


Re: Listview and hibernate question: Objects don't get deleted before the listview getObject() is called

2010-06-25 Thread pieter claassen
Yes, I reload the objects using my DAOs but, I have 2 MySQL databases on the
backend and so far have not been using @Transactional. This might be the
problem.

Now I just have to figure out to configure   tx:annotation-driven
transaction-manager=txManager / for more than one transaction manager and
make sure the different DOAs use the right txManager.

Regards,
Pieter

On Fri, Jun 25, 2010 at 3:30 PM, nino martinez wael 
nino.martinez.w...@gmail.com wrote:

 yeah and grabbig from the dao each time right?


 2010/6/25 pieter claassen pieter.claas...@gmail.com

 Nino,

 No, in this case, I created an inline IModel and overrode the getObject()
 method.

 Pieter


 On Fri, Jun 25, 2010 at 2:59 PM, nino martinez wael 
 nino.martinez.w...@gmail.com wrote:

 are you using a loadable detachable model or?

 2010/6/25 pieter claassen pieter.claas...@gmail.com

 I find that when I delete objects from my ListView, my model object for
 the
 ListView still contains a reference to the object. When the view tries
 to
 render, the object is already removed from the database and I get a null
 response on my hibernate load(). I use opensessioninview and when I
 check my
 logs, the delete statement comes way after the view was rendered.

 It seems that ListView renders the new view before the transaction is
 closed
 (but even then, the delete should be visible to later sql in the same
 transaction).

 Any ideas?
 Regards,
 Pieter



 Log:
 
 Hibernate: delete from ABSTRACTDATASET where ID=?


 ListView:
 ===
ListView documents = new ListView(documents, new IModel() {

public Object getObject() {
return getDocumentList();
}

 





 --
 Pieter Claassen
 musmato.com





-- 
Pieter Claassen
musmato.com


Hibernate session (from Spring bean) during wicketapplication startup

2010-05-24 Thread pieter claassen
I try to bootstrap my MySQL database during the wicket application strartup
but get the following error with a bootstrap method in my
wicketapplication.java. How should I best get  hold of a transaction during
my wicket startup or if this is not possible, what is the most appropriate
alternative?

Rgds,
Pieter


SEVERE: Exception starting filter wicket-spring-hibernate
org.hibernate.HibernateException: No Hibernate Session bound to thread, and
configuration does not allow creation of non-transactional one here
at
org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at
org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:591)
at
com.musmato.dao.application.AbstractBaseFactory.getSession(AbstractBaseFactory.java:24)
at
com.musmato.dao.application.AbstractBaseFactory.getAll(AbstractBaseFactory.java:54)
at
com.musmato.logic.users.UserTools.getUserbyUsername(UserTools.java:18)


Serialization test

2010-01-27 Thread pieter claassen
I want to test the following:
1. Whether I have any private members stored on my pages that are not
a primitive java type, or IModel
2. If they are IModels, that I do call onDetach() on them.

Reflection helps me to answer the 1st question but the second one baffles
me. Any tips on how to verify that I am calling onDetach() on all privately
stored  IModels?

I notice that Martijn has a presentation on the subject here, but there is
just not enough code in there for me to get to solution myself.
http://www.slideshare.net/dashorst/keep-your-wicket-application-in-production

Thanks,
Pieter


Spring-JUnit problems

2009-12-16 Thread pieter claassen
My unit tests stopped working (I failed to notice :-()

I am on wicket 1.4.1
junit 3.8.2
maven

Any help appreciated. Is this a classpath issue?

Rgds
Pieter


This is my errror:

Test set: com.musmato.wicket.pages.AuthHomePageTest
---
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.466 sec
 FAILURE!
testAuthHomePage(com.musmato.wicket.pages.AuthHomePageTest)  Time elapsed:
0.433 sec   ERROR!
java.lang.NoClassDefFoundError: javax/servlet/http/HttpSession
at
com.musmato.wicket.pages.BasePageTestCase.setUp(BasePageTestCase.java:29)
...





This is my test abstract base class
==
public abstract class BasePageTestCase extends TestCase {

private static final String SPRING_CONFIG =
src/main/webapp/WEB-INF/WicketApplicationDefinition.xml;
protected WicketTester tester;

@Override
public void setUp() {
Resource resource = new FileSystemResource(SPRING_CONFIG);
BeanFactory factory = new XmlBeanFactory(resource);
tester = new WicketTester((WicketApplication) factory
 .getBean(WicketApplication));
tester.setupRequestAndResponse();
WicketSession session = (WicketSession) tester.getWicketSession();
session.setUser(new User(test, test, Role.ADMIN));
}


Easymock question

2009-12-16 Thread pieter claassen
I am trying to mock my DAO's, but I am not sure if I understand easymock
correctly.

In my WicketSession I store a user ID and use this to retrieve the current
logged in user from the database (by calling Spring injected
userFactory.getById((String)userId)).

Below is my setUp() for Junit. But the first expect line actually ends up
calling the UserFactory.getID() method. Considering that the factory has no
real connection, this call will obviously fail.

Here is my question: I thought the mock framework hijacks the actually call
and replaces the result with the dummy return value? Is there a way to stop
it from calling the method?

Thanks,
Pieter

 public void setUp() {
mockContext = new AnnotApplicationContextMock();
UserFactory mockuserfactory=createMock(UserFactory.class);
User user=new User();
expect(mockuserfactory.getID(user)).andReturn(1L);
expect(mockuserfactory.getById(1L)).andReturn(user);
replay(mockuserfactory);
mockContext.putBean(userFactory, mockuserfactory);
MockWicketApplication webapp = new MockWicketApplication();
webapp.setMockContext(mockContext);
tester = new WicketTester(webapp);
tester.setupRequestAndResponse();
WicketSession session = (WicketSession) tester.getWicketSession();
session.setUser(user);


}

-- 
Pieter Claassen
musmato.com


Re: Spring-JUnit problems

2009-12-16 Thread pieter claassen
Thanks, that worked.

P

On Wed, Dec 16, 2009 at 10:14 AM, pieter claassen pie...@claassen.co.ukwrote:

 My unit tests stopped working (I failed to notice :-()

 I am on wicket 1.4.1
 junit 3.8.2
 maven

 Any help appreciated. Is this a classpath issue?

 Rgds
 Pieter


 This is my errror:
 
 Test set: com.musmato.wicket.pages.AuthHomePageTest

 ---
 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.466 sec
  FAILURE!
 testAuthHomePage(com.musmato.wicket.pages.AuthHomePageTest)  Time elapsed:
 0.433 sec   ERROR!
 java.lang.NoClassDefFoundError: javax/servlet/http/HttpSession
 at
 com.musmato.wicket.pages.BasePageTestCase.setUp(BasePageTestCase.java:29)
 ...





 This is my test abstract base class
 ==
 public abstract class BasePageTestCase extends TestCase {

 private static final String SPRING_CONFIG =
 src/main/webapp/WEB-INF/WicketApplicationDefinition.xml;
 protected WicketTester tester;

 @Override
 public void setUp() {
 Resource resource = new FileSystemResource(SPRING_CONFIG);
 BeanFactory factory = new XmlBeanFactory(resource);
 tester = new WicketTester((WicketApplication) factory
  .getBean(WicketApplication));
 tester.setupRequestAndResponse();
 WicketSession session = (WicketSession) tester.getWicketSession();
 session.setUser(new User(test, test, Role.ADMIN));
 }





-- 
Pieter Claassen
musmato.com


setVisible(false) kills DraggableBehavior()

2009-11-23 Thread pieter claassen
The code below works but the moment that I set my questioneditorpanel as
invisible to start with (even with the setOutputMarkupPlaceholder(true)),
the the draggable behavior stops working. I don't know why this is
happening? Any tips on where to start looking?

Thanks,
Pieter

QuestionEditPanel.java
==
.
questioneditorpanel=new Label(questionformatpanel,new
Model());
questioneditorpanel.add(new DraggableBehavior());
questioneditorpanel.setOutputMarkupId(true);
//questioneditorpanel.setVisible(false);
questioneditorpanel.setOutputMarkupPlaceholderTag(true);


I replace each of the these questioneditorpanels with an ajax link and add a
new DraggableBehavior to each new QuestionEditorPanel as required.


 AjaxFallbackLink editor = new AjaxFallbackLink(editor) {


@Override
public void onClick(AjaxRequestTarget target) {
QuestionEditorPanel replacement=new
QuestionEditorPanel(questionformatpanel,
questionmodel,templatemodel,panel);
panel.setQuestionFormatPanel(replacement);
replacement.add(new DraggableBehavior());
target.addComponent(replacement);
}
-- 
Pieter Claassen
musmato.com


Re: setVisible(false) kills DraggableBehavior()

2009-11-23 Thread pieter claassen
Sorry, this is from the jwicket-ui-dragdrop-1.4.1 project.

org.wicketstuff.jwicket.ui.dragdrop.DraggableBehavior

I don't know what is in it :-(

This drabable code works fine until I set isVisible(false) on the panel I
want to drag around. Then all ajax events from dragging the panel
disappears.

Regards,
Pieter

On Mon, Nov 23, 2009 at 1:34 PM, Martin Makundi 
martin.maku...@koodaripalvelut.com wrote:

 What is in draggablebehavior? That might be the problem.

 **
 Martin

 2009/11/23 pieter claassen pie...@claassen.co.uk:
  The code below works but the moment that I set my questioneditorpanel as
  invisible to start with (even with the setOutputMarkupPlaceholder(true)),
  the the draggable behavior stops working. I don't know why this is
  happening? Any tips on where to start looking?
 
  Thanks,
  Pieter
 
  QuestionEditPanel.java
  ==
  .
 questioneditorpanel=new Label(questionformatpanel,new
  Model());
 questioneditorpanel.add(new DraggableBehavior());
 questioneditorpanel.setOutputMarkupId(true);
 //questioneditorpanel.setVisible(false);
 questioneditorpanel.setOutputMarkupPlaceholderTag(true);
 
 
  I replace each of the these questioneditorpanels with an ajax link and
 add a
  new DraggableBehavior to each new QuestionEditorPanel as required.
 
 
  AjaxFallbackLink editor = new AjaxFallbackLink(editor) {
 
 
 @Override
 public void onClick(AjaxRequestTarget target) {
 QuestionEditorPanel replacement=new
  QuestionEditorPanel(questionformatpanel,
  questionmodel,templatemodel,panel);
 panel.setQuestionFormatPanel(replacement);
 replacement.add(new DraggableBehavior());
 target.addComponent(replacement);
 }
  --
  Pieter Claassen
  musmato.com
 

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




-- 
Pieter Claassen
musmato.com


Re: setVisible(false) kills DraggableBehavior()

2009-11-23 Thread pieter claassen
Note that in the AjaxLink I create a new replacement panel, add a dragging
behavior to it and then replace the old one with it (code below). My
question is that even though I add a draggable behavior to the new panel and
do the proper replacement, it stops working as soon as I start of with an
invisible panel (with setOutputMarkupPlaceholderTag(true)). I thought the
whole objective of setOutputMarkupPlaceholderTag is to just to do an inline
style change to invisible while holding the rest of the code including the
component id's the same).

public void setQuestionFormatPanel(QuestionEditorPanel qfp){
questioneditorpanel.replaceWith(qfp);
this.questioneditorpanel=qfp;
}

On Mon, Nov 23, 2009 at 2:00 PM, Martin Makundi 
martin.maku...@koodaripalvelut.com wrote:

  This drabable code works fine until I set isVisible(false) on the panel I
  want to drag around. Then all ajax events from dragging the panel
  disappears.

 Do you really expect to drag something that is not rendered on the browser?

 **
 Martin

 
  Regards,
  Pieter
 
  On Mon, Nov 23, 2009 at 1:34 PM, Martin Makundi 
  martin.maku...@koodaripalvelut.com wrote:
 
  What is in draggablebehavior? That might be the problem.
 
  **
  Martin
 
  2009/11/23 pieter claassen pie...@claassen.co.uk:
   The code below works but the moment that I set my questioneditorpanel
 as
   invisible to start with (even with the
 setOutputMarkupPlaceholder(true)),
   the the draggable behavior stops working. I don't know why this is
   happening? Any tips on where to start looking?
  
   Thanks,
   Pieter
  
   QuestionEditPanel.java
   ==
   .
  questioneditorpanel=new Label(questionformatpanel,new
   Model());
  questioneditorpanel.add(new DraggableBehavior());
  questioneditorpanel.setOutputMarkupId(true);
  //questioneditorpanel.setVisible(false);
  questioneditorpanel.setOutputMarkupPlaceholderTag(true);
  
  
   I replace each of the these questioneditorpanels with an ajax link and
  add a
   new DraggableBehavior to each new QuestionEditorPanel as required.
  
  
   AjaxFallbackLink editor = new AjaxFallbackLink(editor) {
  
  
  @Override
  public void onClick(AjaxRequestTarget target) {
  QuestionEditorPanel replacement=new
   QuestionEditorPanel(questionformatpanel,
   questionmodel,templatemodel,panel);
  panel.setQuestionFormatPanel(replacement);
  replacement.add(new DraggableBehavior());
  target.addComponent(replacement);
  }
   --
   Pieter Claassen
   musmato.com
  
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
  --
  Pieter Claassen
  musmato.com
 




-- 
Pieter Claassen
musmato.com


Maven wicketstuff project include

2009-11-19 Thread pieter claassen
What is the correct maven syntax to include wickestuff projects? My code
below fails to find the jquery project.

[svn-revision-number:revision {execution: default}]
snapshot org.wicketstuff:jquery:1.4.3-SNAPSHOT: checking for updates from
wicket-snaps
Downloading:
http://wicketstuff.org/maven/repository/org/wicketstuff/jquery/1.4.3-SNAPSHOT/jquery-1.4.3-SNAPSHOT.pom
Unable to find resource 'org.wicketstuff:jquery:pom:1.4.3-SNAPSHOT' in
repository wicket-snaps (http://wicketstuff.org/maven/repository)
Downloading:
http://wicketstuff.org/maven/repository/org/wicketstuff/jquery/1.4.3-SNAPSHOT/jquery-1.4.3-SNAPSHOT.jar
Unable to find resource 'org.wicketstuff:jquery:jar:1.4.3-SNAPSHOT' in
repository wicket-snaps (http://wicketstuff.org/maven/repository)

[ERROR]BUILD ERROR


pom.xml


repository
idwicket-snaps/id
urlhttp://wicketstuff.org/maven/repository/url
snapshots
enabledtrue/enabled
/snapshots
releases
enabledtrue/enabled
/releases
/repository


dependency
groupIdorg.wicketstuff/groupId
artifactIdjquery/artifactId
version${wicket.version}-SNAPSHOT/version
/dependency


-- 
Pieter Claassen
musmato.com


Re: AjaxFallBackLink updating a listview in a listview (blog entry)

2009-11-19 Thread pieter claassen
Hi Sven, I am trying to implement your changes, but am not sure what you
mean:
I have 3 panels in a page
(QuestionCompletePage
-QuestionCompletePanel-CompletableQuestionPanel-QuestionNavigationPanel).

However, QuestionNavigationPanel, that contains my AjaxLink, belongs to two
execution paths (it is used in QuestionCompletePage and QuestionEditPage).

So I create an interface IRefreshable and have QuestionCompletePanel
implement it (because it contains the container that I want to refresh).

public interface IRefreshable {

public ListComponent getRefreshables();

}

Normally, I would then either have to pass a reference to this panel or
otherwise, navigate down from getPage() to get to the panel. This seems to
be just as much work as including the container for refreshing in the
constructor calls.

Any tips appreciated.

P


B)
 IMHO passing the container into EditableQuestionPanel isn't a good idea -
 why should it know anything about its parent? Instead I'd add a hook method
 into EditableQuestionPanel so that it can notify about changes. The
 containing QuestionEditPanel can then do whatever it needs to update itself
 on an Ajax request.




JQuery slider implementation broken in 1.4?

2009-11-19 Thread pieter claassen
Has anybody recently made the JQuery slider implementation or or even just
ran the demo? I don't get Ajax debug info in my debug window and no data
makes it back to onChange().

Thanks,
Pieter


javascript slider implementation

2009-11-18 Thread pieter claassen
I would like to implement a slider to set the width of a component.

I could not get the Dojo Slider implementation working with wicket 1.4.1 (I
could not get the code in with maven even though the Dojo project built from
SVN, it just doesn't seem to contain the Slider class anymore).

My thinking is to build a very simple slider component that updates a
variable and on mouse-up returns this data to the server.

My approach so far is:
1. Implement my own SliderAbstractAjaxBehavior that in onRequest will accept
the current position of the slider.
2. I will then update the width of my component and mark it for repainting.
3. I will have to develop the javascript to read the slider values and react
to the mouseup event. Where can I look for more information on how to post
data back to onRequest from Javascript? I assume there is a function already
availble in the standard wicket JS implementation?

Any tips appreciated.

Rgds,
Pieter


Re: javascript slider implementation

2009-11-18 Thread pieter claassen
Thanks, this helped a lot.

My component that I want to resize is a WebMarkupContainer and I add my
Slider to it. However, I don't see any output from my onChange method.

here is the java and html. I am not sure what role SliderOptions and
SliderHandleOptions play? Where can I see some example implementations?

Slider slider=new Slider(slider, new
SliderOptions().setMax(100).setMin(0),new SliderHandleOptions(1, 50)) {

@Override
public void onChange(AjaxRequestTarget arg0, String handleid,
int val) {
System.out.println(SLIDER STUFF : +handleid+val);
}
};
add(holder);
holder.add(slider);

html
span class=questionholder wicket:id=holder
a href=# wicket:id=editor(edit)/a
span id=value wicket:id=statement.value/
span wicket:id=navpanel /
span wicket:id=slider/
/span


On Wed, Nov 18, 2009 at 1:51 PM, Martin Grigorov mcgreg...@e-card.bgwrote:

 check wicketstuff-jquery
 there is a slider behavior + demo

 On Wed, 2009-11-18 at 13:04 +0100, pieter claassen wrote:
  I would like to implement a slider to set the width of a component.
 
  I could not get the Dojo Slider implementation working with wicket 1.4.1
 (I
  could not get the code in with maven even though the Dojo project built
 from
  SVN, it just doesn't seem to contain the Slider class anymore).
 
  My thinking is to build a very simple slider component that updates a
  variable and on mouse-up returns this data to the server.
 
  My approach so far is:
  1. Implement my own SliderAbstractAjaxBehavior that in onRequest will
 accept
  the current position of the slider.
  2. I will then update the width of my component and mark it for
 repainting.
  3. I will have to develop the javascript to read the slider values and
 react
  to the mouseup event. Where can I look for more information on how to
 post
  data back to onRequest from Javascript? I assume there is a function
 already
  availble in the standard wicket JS implementation?
 
  Any tips appreciated.
 
  Rgds,
  Pieter



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




-- 
Pieter Claassen
musmato.com


AjaxFallBackLink updating a listview in a listview (blog entry)

2009-11-18 Thread pieter claassen
Hi Guys,

Here is a blog entry on how I update listviews in listviews with Ajax.

http://skeptical-inquirer.blogspot.com/2009/11/updating-listview-in-listview-with-ajax.html

I would appreciate any comments to help me improve this pattern.

Cheers,
Pieter


Re: javascript slider implementation

2009-11-18 Thread pieter claassen
Hi Martin,

I tried to implement your Slider suggestion but even if I duplicate the code
in the examples, I get no feedback to the onChange method. My ajax debug
console also shows nothing so I get the feeling I am missing  some
javascript code here.

I have the jquery-1.4-SNAPSHOT.jar (1.4-20091110.07192) installed (I am
using wicket 1.4.1)

Any suggestions?

Rgds,
Pieter

On Wed, Nov 18, 2009 at 1:51 PM, Martin Grigorov mcgreg...@e-card.bgwrote:

 check wicketstuff-jquery
 there is a slider behavior + demo

 On Wed, 2009-11-18 at 13:04 +0100, pieter claassen wrote:
  I would like to implement a slider to set the width of a component.
 
  I could not get the Dojo Slider implementation working with wicket 1.4.1
 (I
  could not get the code in with maven even though the Dojo project built
 from
  SVN, it just doesn't seem to contain the Slider class anymore).
 
  My thinking is to build a very simple slider component that updates a
  variable and on mouse-up returns this data to the server.
 
  My approach so far is:
  1. Implement my own SliderAbstractAjaxBehavior that in onRequest will
 accept
  the current position of the slider.
  2. I will then update the width of my component and mark it for
 repainting.
  3. I will have to develop the javascript to read the slider values and
 react
  to the mouseup event. Where can I look for more information on how to
 post
  data back to onRequest from Javascript? I assume there is a function
 already
  availble in the standard wicket JS implementation?
 
  Any tips appreciated.
 
  Rgds,
  Pieter



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




-- 
Pieter Claassen
musmato.com


Re: Listview in a listview refresh with AjaxLink don't work

2009-11-17 Thread pieter claassen
Pedro,

Improved version now works. Here is my onclick for the AjaxFallBackLink.
Much of it I think is not best practice. Any tips on making this code
better?

Thanks a million for your help!

P

 AjaxFallbackLink up = new AjaxFallbackLink(up) {

@Override
public void onClick(AjaxRequestTarget target) {
AbstractDataSet dataset = datasetmodel.getEntity();
MarkupContainer container=null;
container=getParent();
while(!container.getId().equals(rows)){
container=container.getParent();
}
ListView view=null;
if (container instanceof ListView){
view=(ListView)container;
}
dataset.moveQuestionUp(question); //update the domain model
List list=QuestionProcessor.getMatrixToList(view.getList());
//extract the listview model data
QuestionProcessor.moveQuestionUp(list, question);
view.setList(QuestionProcessor.getListToMatrix(list,
Boolean.TRUE)); //reset the listview model data
adsf.store(dataset); //store my domain data to persist
target.addComponent(outercontainer); //repaint the whole lot
}
};



On Tue, Nov 17, 2009 at 1:47 PM, Pedro Santos pedros...@gmail.com wrote:
 Hi Pieter,
 When you call template.moveQuestionUp(question) you are altering the order
 of the template entity questions list. I think this isn't the same list on
 the row listview model, although both have the same objects.
 All lists used by repeaters are created by QuestionProcessor, you can make
 sure of using those lists operation over rowlistview.getlist() on
 moveQuestionUp implementation.

 On Sun, Nov 15, 2009 at 6:56 AM, pieter claassen 
pieter.claas...@gmail.com
 wrote:

 Hi Pedro,


 Here it is.

 So, I basically move the question up or down the array.

public void moveQuestionUp(QuestionBase question) {
int idx = questions.indexOf(question);
if (idx  0) {
questions.remove(question);
questions.add(idx - 1, question);
}
}

 I think that the listview is being redrawn in HTML but the matrix of
 data underlying it (that I retrieve here in the main page)

 ListListQuestionBase rows =


QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);

 does not get refreshed. I think I need to find a way to reload the
 data for the listview, from within my panel on a page.

 Cheers,
 Pieter




 On Sun, Nov 15, 2009 at 12:14 AM, Pedro Santos pedros...@gmail.com
 wrote:
  Can you send the moveQuestionUp implementation?
 
  On Sat, Nov 14, 2009 at 9:03 PM, pieter claassen
  pieter.claas...@gmail.com
  wrote:
 
  I am trying to follow wicket in action advice P263 but
 
  I have a ListView in a ListView with a panel added to my inner
  listview. On that panel, I have  an AjaxLink and I want to move items
  in the order of the listview around. But to display them, I need to
  refresh my matrix. Nothing seems to work. Any tips or references.
 
  QuestionEditPanel.html
  =
 wicket:extend
 div id=document
 span wicket:id=parent
 div wicket:id=rows
 span wicket:id=row
 span wicket:id=question /
 /span
 /div
 /span
 /div
 /wicket:extend
 
  QuestionEditPanel.java
  ==
 
 final WebMarkupContainer parent=new
  WebMarkupContainer(parent);
 add(parent);
 parent.setOutputMarkupId(true);
 ListListQuestionBase rows =
 
 
 
QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);
 ListView rowslistview = new ListView(rows, rows) {
 
 @Override
 protected void populateItem(ListItem item) {
 ListQuestionBase row = (ListQuestionBase)
  item.getModelObject();
 ListView rowlistview = new ListView(row, row) {
 
 @Override
 protected void populateItem(ListItem item) {
 final QuestionBase question = (QuestionBase)
  item.getModelObject();
 item.setModel(new
  CompoundPropertyModel(question));
 EditableQuestionPanel questionpanel=new
  EditableQuestionPanel(question, new
  QuestionBaseWebModel(question),templateWebModel,parent);
 item.add(questionpanel);
  
 
 
  and then on my EditableQuestionPanel.java I have :
 
  AjaxLink up = new AjaxLink(up) {
 
 @Override
 public void onClick(AjaxRequestTarget target) {
 target.addComponent(parent);
 Template template = templatemodel.getEntity();
 template.moveQuestionUp(question

AjaxFallBackLink driving me nuts!

2009-11-17 Thread pieter claassen
Can anybody please enlighten me why this doesn't work (ok end of the day,
maybe it really is something small). I am clearly changing the underlying
model data, but how to tell questionEditPanel to pick that change up. I
tried setDefaultModel(new TemplateWebModel(template)),
templateEditPanel.modelChanged() and nothing works.  Any tips appreciated.

P

AjaxFallbackLink newpage = new AjaxFallbackLink(newpage) {

@Override
public void onClick(AjaxRequestTarget target) {
QuestionBase newpage = new NewPage();
Template template = templatewebmodel.getEntity();
template.addQuestion(newpage);
templateFactory.store(template);
target.addComponent(questionEditPanel);
}
};
add(newpage);
questionEditPanel = new QuestionEditPanel(questionrenderpanel,
templatewebmodel);
questionEditPanel.setOutputMarkupId(true);
add(questionEditPanel);

--


Re: Listview in a listview refresh with AjaxLink don't work

2009-11-15 Thread pieter claassen
Hi Pedro,


Here it is.

So, I basically move the question up or down the array.

public void moveQuestionUp(QuestionBase question) {
int idx = questions.indexOf(question);
if (idx  0) {
questions.remove(question);
questions.add(idx - 1, question);
}
}

I think that the listview is being redrawn in HTML but the matrix of
data underlying it (that I retrieve here in the main page)

ListListQuestionBase rows =
QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);

does not get refreshed. I think I need to find a way to reload the
data for the listview, from within my panel on a page.

Cheers,
Pieter




On Sun, Nov 15, 2009 at 12:14 AM, Pedro Santos pedros...@gmail.com wrote:
 Can you send the moveQuestionUp implementation?

 On Sat, Nov 14, 2009 at 9:03 PM, pieter claassen pieter.claas...@gmail.com
 wrote:

 I am trying to follow wicket in action advice P263 but

 I have a ListView in a ListView with a panel added to my inner
 listview. On that panel, I have  an AjaxLink and I want to move items
 in the order of the listview around. But to display them, I need to
 refresh my matrix. Nothing seems to work. Any tips or references.

 QuestionEditPanel.html
 =
        wicket:extend
            div id=document
                span wicket:id=parent
                    div wicket:id=rows
                        span wicket:id=row
                            span wicket:id=question /
                        /span
                    /div
                /span
            /div
        /wicket:extend

 QuestionEditPanel.java
 ==

        final WebMarkupContainer parent=new WebMarkupContainer(parent);
        add(parent);
        parent.setOutputMarkupId(true);
        ListListQuestionBase rows =

 QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);
        ListView rowslistview = new ListView(rows, rows) {

           �...@override
            protected void populateItem(ListItem item) {
                ListQuestionBase row = (ListQuestionBase)
 item.getModelObject();
                ListView rowlistview = new ListView(row, row) {

                   �...@override
                    protected void populateItem(ListItem item) {
                        final QuestionBase question = (QuestionBase)
 item.getModelObject();
                        item.setModel(new CompoundPropertyModel(question));
                        EditableQuestionPanel questionpanel=new
 EditableQuestionPanel(question, new
 QuestionBaseWebModel(question),templateWebModel,parent);
                        item.add(questionpanel);
 


 and then on my EditableQuestionPanel.java I have :

 AjaxLink up = new AjaxLink(up) {

           �...@override
            public void onClick(AjaxRequestTarget target) {
                target.addComponent(parent);
                Template template = templatemodel.getEntity();
                template.moveQuestionUp(question);
                tf.store(template);
            }
        };
 --
 Pieter Claassen
 musmato.com

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




 --
 Pedro Henrique Oliveira dos Santos




-- 
Pieter Claassen
musmato.com

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



Listview in a listview refresh with AjaxLink don't work

2009-11-15 Thread pieter claassen
Hi Pedro,

Here it is.

So, I basically move the question up or down the array.

   public void moveQuestionUp(QuestionBase question) {
       int idx = questions.indexOf(question);
       if (idx  0) {
           questions.remove(question);
           questions.add(idx - 1, question);
       }
   }

I think that the listview is being redrawn in HTML but the matrix of
data underlying it (that I retrieve here in the main page)

ListListQuestionBase rows =
QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);

does not get refreshed. I think I need to find a way to reload the
data for the listview, from within my panel on a page.

Cheers,
Pieter




On Sun, Nov 15, 2009 at 12:14 AM, Pedro Santos pedros...@gmail.com wrote:
 Can you send the moveQuestionUp implementation?

 On Sat, Nov 14, 2009 at 9:03 PM, pieter claassen pieter.claas...@gmail.com
 wrote:

 I am trying to follow wicket in action advice P263 but

 I have a ListView in a ListView with a panel added to my inner
 listview. On that panel, I have  an AjaxLink and I want to move items
 in the order of the listview around. But to display them, I need to
 refresh my matrix. Nothing seems to work. Any tips or references.

 QuestionEditPanel.html
 =
        wicket:extend
            div id=document
                span wicket:id=parent
                    div wicket:id=rows
                        span wicket:id=row
                            span wicket:id=question /
                        /span
                    /div
                /span
            /div
        /wicket:extend

 QuestionEditPanel.java
 ==

        final WebMarkupContainer parent=new WebMarkupContainer(parent);
        add(parent);
        parent.setOutputMarkupId(true);
        ListListQuestionBase rows =

 QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);
        ListView rowslistview = new ListView(rows, rows) {

           �...@override
            protected void populateItem(ListItem item) {
                ListQuestionBase row = (ListQuestionBase)
 item.getModelObject();
                ListView rowlistview = new ListView(row, row) {

                   �...@override
                    protected void populateItem(ListItem item) {
                        final QuestionBase question = (QuestionBase)
 item.getModelObject();
                        item.setModel(new CompoundPropertyModel(question));
                        EditableQuestionPanel questionpanel=new
 EditableQuestionPanel(question, new
 QuestionBaseWebModel(question),templateWebModel,parent);
                        item.add(questionpanel);
 


 and then on my EditableQuestionPanel.java I have :

 AjaxLink up = new AjaxLink(up) {

           �...@override
            public void onClick(AjaxRequestTarget target) {
                target.addComponent(parent);
                Template template = templatemodel.getEntity();
                template.moveQuestionUp(question);
                tf.store(template);
            }
        };
 --
 Pieter Claassen
 musmato.com

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




 --
 Pedro Henrique Oliveira dos Santos


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



Listview in a listview refresh with AjaxLink don't work

2009-11-14 Thread pieter claassen
I am trying to follow wicket in action advice P263 but

I have a ListView in a ListView with a panel added to my inner
listview. On that panel, I have  an AjaxLink and I want to move items
in the order of the listview around. But to display them, I need to
refresh my matrix. Nothing seems to work. Any tips or references.

QuestionEditPanel.html
=
wicket:extend
div id=document
span wicket:id=parent
div wicket:id=rows
span wicket:id=row
span wicket:id=question /
/span
/div
/span
/div
/wicket:extend

QuestionEditPanel.java
==

final WebMarkupContainer parent=new WebMarkupContainer(parent);
add(parent);
parent.setOutputMarkupId(true);
ListListQuestionBase rows =
QuestionProcessor.getQuestionMatrix(templateWebModel.getEntity().getQuestions(),true);
ListView rowslistview = new ListView(rows, rows) {

@Override
protected void populateItem(ListItem item) {
ListQuestionBase row = (ListQuestionBase)
item.getModelObject();
ListView rowlistview = new ListView(row, row) {

@Override
protected void populateItem(ListItem item) {
final QuestionBase question = (QuestionBase)
item.getModelObject();
item.setModel(new CompoundPropertyModel(question));
EditableQuestionPanel questionpanel=new
EditableQuestionPanel(question, new
QuestionBaseWebModel(question),templateWebModel,parent);
item.add(questionpanel);



and then on my EditableQuestionPanel.java I have :

AjaxLink up = new AjaxLink(up) {

@Override
public void onClick(AjaxRequestTarget target) {
target.addComponent(parent);
Template template = templatemodel.getEntity();
template.moveQuestionUp(question);
tf.store(template);
}
};
-- 
Pieter Claassen
musmato.com

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



Re: Force page reload/re-render

2009-11-10 Thread pieter claassen
Hi Pedro,

I tried setResponsePage(getPage()) but the problem is it does not
re-render controls on the page.

setResponsePage(getPage().getClass()) only works for stateless pages
and on most of my pages, I pass params via the constructor.

The javascript option will be a last resort, but it seems to be not
the most elegant solution.

Rgds,

On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote:
 if(userSetWasChanged){
 target.appendJavascript(window.location.reload());
 or
 setResponsePage(getPage());
 or
 setResponsePage(getPage().getClass());
 }


 On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com
 wrote:

 I have a link on a panel that is included in many pages. When the user
 clicks on the link, I change something in the user settings that will
 affect what gets displayed on the page. However, for that to work, I
 need to reload the page after the user clicked on the link as by
 default the other components that now need to be checked for
 conditional visibility don't re-render (why not?). setResponsePage()
 requires me to pass into the panel a target page and this becomes
 complex when you have a mix of statefull and stateless pages as
 targets (and it just doesn't feel right).

 I am sure there must be an easier way to just re-render a page?

 Any tips?

 Thanks,
 pieter

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




 --
 Pedro Henrique Oliveira dos Santos




-- 
Pieter Claassen
musmato.com

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



Re: Force page reload/re-render

2009-11-10 Thread pieter claassen
Both of the suggestions I think requires me to modify the logic of the
controls (either to keep track of which ones need to be updated or by
placing the rendering logic in onBeforeRender()). I think this is a
lot of work for something relative straight forward and also any
changes to permission structures and I have to modify controls.

Is there no way that I can mark a page obtained via getPage() as
requiring re-rendering? I tried getPage().dirty() before the
setResponsePage() but that didn't do anything.

Thanks for the feedback though.
P

On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote:
 I tried setResponsePage(getPage()) but the problem is it does not
 re-render controls on the page.

 Where do you implement your control ( update logic )? Consider do it
 overriding Component.onBeforeRender method

 On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
 pieter.claas...@gmail.com wrote:

 Hi Pedro,

 I tried setResponsePage(getPage()) but the problem is it does not
 re-render controls on the page.

 setResponsePage(getPage().getClass()) only works for stateless pages
 and on most of my pages, I pass params via the constructor.

 The javascript option will be a last resort, but it seems to be not
 the most elegant solution.

 Rgds,

 On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com
 wrote:
  if(userSetWasChanged){
  target.appendJavascript(window.location.reload());
  or
  setResponsePage(getPage());
  or
  setResponsePage(getPage().getClass());
  }
 
 
  On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
  pieter.claas...@gmail.com
  wrote:
 
  I have a link on a panel that is included in many pages. When the user
  clicks on the link, I change something in the user settings that will
  affect what gets displayed on the page. However, for that to work, I
  need to reload the page after the user clicked on the link as by
  default the other components that now need to be checked for
  conditional visibility don't re-render (why not?). setResponsePage()
  requires me to pass into the panel a target page and this becomes
  complex when you have a mix of statefull and stateless pages as
  targets (and it just doesn't feel right).
 
  I am sure there must be an easier way to just re-render a page?
 
  Any tips?
 
  Thanks,
  pieter
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
  --
  Pedro Henrique Oliveira dos Santos
 



 --
 Pieter Claassen
 musmato.com



 --
 Pedro Henrique Oliveira dos Santos




-- 
Pieter Claassen
musmato.com

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



Re: Force page reload/re-render

2009-11-10 Thread pieter claassen
Hi Ernesto,

To recap, I have a control panel visible on each and every page and in
that control panel, you can select the appropriate role you want to
use. Based on that role some menu items will be visible or not
(example below is correct). I am sure this problem has been solved
before :-0 as this is a very normal usecase for context sensitive
navigation.

It seems that there is no way to force the page to re-render using getPage()?

Thanks for the feedback so far. I keep on coming up against this issue
and have not found a reasonable solution to the problem. The
javascript option seems to be best so far.

Pieter

On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
reier...@gmail.com wrote:
 Even if you re-render your page components that are not dynamic will not
 change their state: unless you create a new instance of the page, I guess.
 By this I mean.

 class MyPanel  {
   public MyPanel(id) {
   PanelB panelB = new Panel(B);
   panelB.setVisible(getSomeCondition());
   
   }
 }

 Even if condition getSomeCondition() change, and you re-render  MyPanel, or
 the whole page, panelB will still be not visible. So, if you want something
 to be dynamic you have to program it to be dynamic.

 Best,

 Ernesto


 On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen pieter.claas...@gmail.com
 wrote:

 Both of the suggestions I think requires me to modify the logic of the
 controls (either to keep track of which ones need to be updated or by
 placing the rendering logic in onBeforeRender()). I think this is a
 lot of work for something relative straight forward and also any
 changes to permission structures and I have to modify controls.

 Is there no way that I can mark a page obtained via getPage() as
 requiring re-rendering? I tried getPage().dirty() before the
 setResponsePage() but that didn't do anything.

 Thanks for the feedback though.
 P

 On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote:
  I tried setResponsePage(getPage()) but the problem is it does not
  re-render controls on the page.
 
  Where do you implement your control ( update logic )? Consider do it
  overriding Component.onBeforeRender method
 
  On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
  pieter.claas...@gmail.com wrote:
 
  Hi Pedro,
 
  I tried setResponsePage(getPage()) but the problem is it does not
  re-render controls on the page.
 
  setResponsePage(getPage().getClass()) only works for stateless pages
  and on most of my pages, I pass params via the constructor.
 
  The javascript option will be a last resort, but it seems to be not
  the most elegant solution.
 
  Rgds,
 
  On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com
  wrote:
   if(userSetWasChanged){
   target.appendJavascript(window.location.reload());
   or
   setResponsePage(getPage());
   or
   setResponsePage(getPage().getClass());
   }
  
  
   On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
   pieter.claas...@gmail.com
   wrote:
  
   I have a link on a panel that is included in many pages. When the
   user
   clicks on the link, I change something in the user settings that
   will
   affect what gets displayed on the page. However, for that to work, I
   need to reload the page after the user clicked on the link as by
   default the other components that now need to be checked for
   conditional visibility don't re-render (why not?). setResponsePage()
   requires me to pass into the panel a target page and this becomes
   complex when you have a mix of statefull and stateless pages as
   targets (and it just doesn't feel right).
  
   I am sure there must be an easier way to just re-render a page?
  
   Any tips?
  
   Thanks,
   pieter
  
  
   -
   To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
   For additional commands, e-mail: users-h...@wicket.apache.org
  
  
  
  
   --
   Pedro Henrique Oliveira dos Santos
  
 
 
 
  --
  Pieter Claassen
  musmato.com
 
 
 
  --
  Pedro Henrique Oliveira dos Santos
 



 --
 Pieter Claassen
 musmato.com





-- 
Pieter Claassen
musmato.com

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



Re: Force page reload/re-render

2009-11-10 Thread pieter claassen
Thanks for all the feedback. onBeforeRender() works like a charm.

Pieter

On Tue, Nov 10, 2009 at 2:51 PM, Michael O'Cleirigh
michael.ocleir...@rivulet.ca wrote:
 Hi Pieter,

 Components that have .setVisible(false) will never be evaluated again
 automatically.  You  need to call .setVisible(true) on all that apply.

 One way would be control visibility in the base panel by overriding
 onBeforeRender() to handle all the cases in one place. e.g.

 class ControlPanel  extends Panel {

   protected void onBeforeRender () {
       Role role = getModelObject();

       caseOnePanel.setVisible(false);
       caseTwoPanel.setVisible (false);

       if (role instanceof CaseOne) {
            caseOnePanel.setVisible (true);
       }
       else if (role instanceof CaseTwo) {
           caseTwoPanel.setVisible (true);
      }
  }
 }

 Or you could override .isVisible() in your sub panels to control when they
 are visible.

 I like the on before render way myself because there is no performance
 penalty if the visibility logic is complex (Component.isVisible() is called
 alot during the rendering phase).

 Regards,

 Mike

 To recap, I have a control panel visible on each and every page and in
 that control panel, you can select the appropriate role you want to
 use. Based on that role some menu items will be visible or not
 (example below is correct). I am sure this problem has been solved
 before :-0 as this is a very normal usecase for context sensitive
 navigation.

 It seems that there is no way to force the page to re-render using
 getPage()?

 Thanks for the feedback so far. I keep on coming up against this issue
 and have not found a reasonable solution to the problem. The
 javascript option seems to be best so far.

 Pieter

 On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
 reier...@gmail.com wrote:


 Even if you re-render your page components that are not dynamic will
 not
 change their state: unless you create a new instance of the page, I
 guess.
 By this I mean.

 class MyPanel  {
      public MyPanel(id) {
          PanelB panelB = new Panel(B);
          panelB.setVisible(getSomeCondition());
          
      }
 }

 Even if condition getSomeCondition() change, and you re-render  MyPanel,
 or
 the whole page, panelB will still be not visible. So, if you want
 something
 to be dynamic you have to program it to be dynamic.

 Best,

 Ernesto


 On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen
 pieter.claas...@gmail.com
 wrote:


 Both of the suggestions I think requires me to modify the logic of the
 controls (either to keep track of which ones need to be updated or by
 placing the rendering logic in onBeforeRender()). I think this is a
 lot of work for something relative straight forward and also any
 changes to permission structures and I have to modify controls.

 Is there no way that I can mark a page obtained via getPage() as
 requiring re-rendering? I tried getPage().dirty() before the
 setResponsePage() but that didn't do anything.

 Thanks for the feedback though.
 P

 On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com
 wrote:


 I tried setResponsePage(getPage()) but the problem is it does not
 re-render controls on the page.

 Where do you implement your control ( update logic )? Consider do it
 overriding Component.onBeforeRender method

 On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
 pieter.claas...@gmail.com wrote:


 Hi Pedro,

 I tried setResponsePage(getPage()) but the problem is it does not
 re-render controls on the page.

 setResponsePage(getPage().getClass()) only works for stateless pages
 and on most of my pages, I pass params via the constructor.

 The javascript option will be a last resort, but it seems to be not
 the most elegant solution.

 Rgds,

 On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com
 wrote:


 if(userSetWasChanged){
 target.appendJavascript(window.location.reload());
 or
 setResponsePage(getPage());
 or
 setResponsePage(getPage().getClass());
 }


 On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
 pieter.claas...@gmail.com
 wrote:


 I have a link on a panel that is included in many pages. When the
 user
 clicks on the link, I change something in the user settings that
 will
 affect what gets displayed on the page. However, for that to work, I
 need to reload the page after the user clicked on the link as by
 default the other components that now need to be checked for
 conditional visibility don't re-render (why not?). setResponsePage()
 requires me to pass into the panel a target page and this becomes
 complex when you have a mix of statefull and stateless pages as
 targets (and it just doesn't feel right).

 I am sure there must be an easier way to just re-render a page?

 Any tips?

 Thanks,
 pieter



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

Re: editing objects, backed by LoadableDetachableModels

2009-11-10 Thread pieter claassen
Hi Pieter,

I don't use Hibernate, but db4o. The principle however  might help you.

I inject my factory methods into my pages using Spring (but that is a
minor detail) and when I make a change to a domain object, I always
store the object first before reloading the page (or in this case,
rendering the ajax changes). When the page reloads, it loads the
modified object from the database. This is important to also ensure
your domain objects are persisted otherwise, they might still hang
around in wicket, but might not be stored in the db.

So you need to do something like

public void onClick(AjaxRequestTarget target){
   employee. addAccount(new Account());
   employeeFactory.store(employee);
...
}


Rgds,
Pieter

On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe
pieter.degrae...@systemworks.be wrote:
 Hi,

 I can't imagine that I'm the only one with the following situation.

 I have a page which edits an 'Employee'. Since I use hibernate and spring I
 use the LDM togeather with the OpenSessionInView.
 This works great (==No more LazyLoadExceptions at all...)

 But The Employee has a propertie accounts, which is a collection of
 Account objects. I'm showing these objects using a Listview.
 Now I want to add an Ajax link ('Add new account), which adds a fresh new
 Account object. I add the containing form to the AjaxRequestTarget so the
 ListView refreshes.

 Unfortunately, this approach never works, since my Employee is always
 reloaded from the database each reques.

 (I even think the same problem shows up when you do the same without ajax..)

 What is the best approach to deal with this?

 --
 Pieter Degraeuwe
 Systemworks bvba
 Belgiëlaan 61
 9070 Destelbergen
 GSM: +32 (0)485/68.60.85
 Email: pieter.degrae...@systemworks.be
 visit us at http://www.systemworks.be




-- 
Pieter Claassen
musmato.com

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



Re: editing objects, backed by LoadableDetachableModels

2009-11-10 Thread pieter claassen
Hi Pieter,

Ok, what I do in situations like this is to create a new transient,
serializable object (not stored in the DB) and pass it between wicket
pages as needed. With db4o, any java object can be stored at some
point by calling factory.store(object). Not sure about hibernate.

Imagine you need to configure an object using multiple screens in a
wizzard. Then just create the object, pass it from page to page in the
constructors and in the last page, store it in the db.

Rgds,
Pieter


On Tue, Nov 10, 2009 at 9:31 PM, Pieter Degraeuwe
pieter.degrae...@systemworks.be wrote:
 Thanks for your reply. In some situations your solution might be sufficient,
 but in my situation I'm affraid not...

 I cannot commit an empty Account in the db due constraint reasons. And, I
 actually only want to save the Employee in the database when the user
 presses the ' Save' button, not when he is adding/ modifying some Accounts.
 (So, in other words, the user can always 'Cancel' his actions...



 On Tue, Nov 10, 2009 at 9:16 PM, pieter claassen pieter.claas...@gmail.com
 wrote:

 Hi Pieter,

 I don't use Hibernate, but db4o. The principle however  might help you.

 I inject my factory methods into my pages using Spring (but that is a
 minor detail) and when I make a change to a domain object, I always
 store the object first before reloading the page (or in this case,
 rendering the ajax changes). When the page reloads, it loads the
 modified object from the database. This is important to also ensure
 your domain objects are persisted otherwise, they might still hang
 around in wicket, but might not be stored in the db.

 So you need to do something like

 public void onClick(AjaxRequestTarget target){
   employee. addAccount(new Account());
   employeeFactory.store(employee);
 ...
 }


 Rgds,
 Pieter

 On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe
 pieter.degrae...@systemworks.be wrote:
  Hi,
 
  I can't imagine that I'm the only one with the following situation.
 
  I have a page which edits an 'Employee'. Since I use hibernate and
  spring I
  use the LDM togeather with the OpenSessionInView.
  This works great (==No more LazyLoadExceptions at all...)
 
  But The Employee has a propertie accounts, which is a collection of
  Account objects. I'm showing these objects using a Listview.
  Now I want to add an Ajax link ('Add new account), which adds a fresh
  new
  Account object. I add the containing form to the AjaxRequestTarget so
  the
  ListView refreshes.
 
  Unfortunately, this approach never works, since my Employee is always
  reloaded from the database each reques.
 
  (I even think the same problem shows up when you do the same without
  ajax..)
 
  What is the best approach to deal with this?
 
  --
  Pieter Degraeuwe
  Systemworks bvba
  Belgiëlaan 61
  9070 Destelbergen
  GSM: +32 (0)485/68.60.85
  Email: pieter.degrae...@systemworks.be
  visit us at http://www.systemworks.be
 



 --
 Pieter Claassen
 musmato.com

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




 --
 Pieter Degraeuwe
 Systemworks bvba
 Belgiëlaan 61
 9070 Destelbergen
 GSM: +32 (0)485/68.60.85
 Email: pieter.degrae...@systemworks.be
 visit us at http://www.systemworks.be




-- 
Pieter Claassen
musmato.com

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



Re: User count

2009-11-09 Thread pieter claassen
You can also use your logger implementation and then log in a format
that a log analysis tool can read. This however, is a very old style
approach compared to analytics in my opinion. The quality of the
analysis and ease of implementation with analytics is just so much
better.

http://en.wikipedia.org/wiki/List_of_web_analytics_software

Rgds,
Pieter

On Mon, Nov 9, 2009 at 2:20 PM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 External analytics is much more simpler to manage.

 **
 Martin

 2009/11/9 vela vela@gmail.com:

 Hello again,

 can't we count it using the wicket application, some thing like this in jsp


 %! int i= 0;%
 % out.println(People visited +(++i)); %



 --

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





-- 
Pieter Claassen
musmato.com

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



Force page reload/re-render

2009-11-09 Thread pieter claassen
I have a link on a panel that is included in many pages. When the user
clicks on the link, I change something in the user settings that will
affect what gets displayed on the page. However, for that to work, I
need to reload the page after the user clicked on the link as by
default the other components that now need to be checked for
conditional visibility don't re-render (why not?). setResponsePage()
requires me to pass into the panel a target page and this becomes
complex when you have a mix of statefull and stateless pages as
targets (and it just doesn't feel right).

I am sure there must be an easier way to just re-render a page?

Any tips?

Thanks,
pieter

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



Attribute modified question

2009-11-03 Thread pieter claassen
I am sure I am doing something very silly here but 

When I add the following AttributeModifier in my onBeforeRender()
method, the solution works as expected (so I load an image that
indicates that this page is selected)

icon.add(new AttributeModifier(this.src='
, null, true, new Model(urlFor(active)+';)));

However, when I abstract that same code into a private class, the
solution still works and the correct image loads that indicates which
page I am on, but the browser, never completes the request (so the
spinning wheel on the tab keeps on spinning).

icon.add(new ActivateImage(onload, active));
.
 private class ActivateImage extends AttributeModifier {

    private ActivateImage(String id, final ResourceReference ref) {
    super(id, null, true, new Model(this.src=' + urlFor(ref) + ';));
    }
    }

Any ideas?

Thanks,
Pieter

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



Attribute modifier to track location on pages stops request from completing

2009-11-01 Thread pieter claassen
I am sure I am doing something very silly here but 

When I add the following AttributeModifier in my onBeforeRender() method,
the solution works as expected (so I load an image that indicates that this
page is selected)

icon.add(new AttributeModifier(this.src=', null, true, new
Model(urlFor(active)+';)));

However, when I abstract that same code into a private class, the solution
still works and the correct image loads that indicates which page I am on,
but the browser, never completes the request (so the spinning wheel on the
tab keeps on spinning).

icon.add(new ActivateImage(onload, active));
.
 private class ActivateImage extends AttributeModifier {

private ActivateImage(String id, final ResourceReference ref) {
super(id, null, true, new Model(this.src=' + urlFor(ref) +
';));
}
}

Any ideas?

Thanks,
Pieter


Re: urlFor(ResourceReference) strangeness

2009-10-31 Thread pieter claassen
Alex,

My apologies, but I cannot reproduce this issue again. Even if I mount a
page and then land on that page, I now get the correct behaviour with the
default URL encoding strategy. I am wondering if I called the correct
urlFor()? No good speculating on this though

If I see this again, I will investigate and file a bug if needed.

Thanks for the feedback.
Pieter

On Wed, Oct 28, 2009 at 10:56 AM, Alex Objelean alex_objel...@yahoo.comwrote:


 Still, is this acceptable for you? Is my statement about mounting true? If
 it
 is, could you create a jira issue for this?

 Alex


 pieter claassen-2 wrote:
 
  Alex,
 
  The problem went away. I had some pages mounted (I landed on a mounted
  page)
  and others not so as soon as I removed all the mounted pages, the problem
  went away).
 
  Rgds,
  Pieter
 
  On Wed, Oct 28, 2009 at 7:31 AM, Alex Objelean
  alex_objel...@yahoo.comwrote:
 
 
  I am pretty sure, it is a bug. The reason why the
  urlFor(ResourceReference)
  is not working properly is because you are using
  BookmarkablePageRequestTargetUrlCodingStrategy for page mounting or a
  similar strategy which encodes the params like this:
  http://server/context/param1/value1/param2/value2 ... To prove that
 this
  is
  a bug, try to change (just for test purpose) the mounting to
  QueryStringUrlCodingStrategy, to make the url look like this:
  http://server/context?param1=value1. I suspect that when the url is
  built,
  it depends on the page url from where the urlFor(ResourceReference) is
  called... and wicket doesn't remove the parameters from the url and mess
  this up... The real problem is when you are trying to build an absolute
  url
  for a ResourceReference. If this is indeed the reason of the problem, we
  should raise a jira issue...
 
  Alex Objelean
 
 
  pieter claassen-2 wrote:
  
   Ok, but I have a panel and I want to add an Image to the panel but
 when
  I
   log into my application I get the ../../.. prefix, and the
   ResourceReference
   then fails. However, once I click on any link, the prefix disappears
  and
   then my panel can find the ResourceReference. Am I misunderstanding
 how
   resource references should be used?
  
   Thanks,
   Pieter
  
   On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley ryan...@gmail.com
  wrote:
  
   urlFor( ) uses the current request to get a relative path.  If the
   location
   you are calling urlFor() from changes, it will get a new location
  
   Note the only difference between the two urls is the ../../.. prefix
  
  
   On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
  
WHen I start my application, my urlFor() returns a different URL
 than
   when
   I
   call it a second time?
  
 ResourceReference iconref = new ResourceReference(anchorclass,
   iconname);
 System.out.println(URL: +urlFor(iconref));
  
   First time it returns:
   URL:
  
  
 
 ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
  
   second time:
   URL:
  
  
 
 resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
  
   Any ideas?
  
   Thanks
   Pieter
   --
  
  
  
   -
   To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
   For additional commands, e-mail: users-h...@wicket.apache.org
  
  
  
  
   --
   Pieter Claassen
   musmato.com
  
  
 
  --
  View this message in context:
 
 http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26089957.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
 
 
 
 
  --
  Pieter Claassen
  musmato.com
 
 

 --
 View this message in context:
 http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26091991.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




-- 
Pieter Claassen
musmato.com


Re: urlFor(ResourceReference) strangeness

2009-10-28 Thread pieter claassen
Alex,

The problem went away. I had some pages mounted (I landed on a mounted page)
and others not so as soon as I removed all the mounted pages, the problem
went away).

Rgds,
Pieter

On Wed, Oct 28, 2009 at 7:31 AM, Alex Objelean alex_objel...@yahoo.comwrote:


 I am pretty sure, it is a bug. The reason why the urlFor(ResourceReference)
 is not working properly is because you are using
 BookmarkablePageRequestTargetUrlCodingStrategy for page mounting or a
 similar strategy which encodes the params like this:
 http://server/context/param1/value1/param2/value2 ... To prove that this
 is
 a bug, try to change (just for test purpose) the mounting to
 QueryStringUrlCodingStrategy, to make the url look like this:
 http://server/context?param1=value1. I suspect that when the url is built,
 it depends on the page url from where the urlFor(ResourceReference) is
 called... and wicket doesn't remove the parameters from the url and mess
 this up... The real problem is when you are trying to build an absolute url
 for a ResourceReference. If this is indeed the reason of the problem, we
 should raise a jira issue...

 Alex Objelean


 pieter claassen-2 wrote:
 
  Ok, but I have a panel and I want to add an Image to the panel but when I
  log into my application I get the ../../.. prefix, and the
  ResourceReference
  then fails. However, once I click on any link, the prefix disappears and
  then my panel can find the ResourceReference. Am I misunderstanding how
  resource references should be used?
 
  Thanks,
  Pieter
 
  On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley ryan...@gmail.com
 wrote:
 
  urlFor( ) uses the current request to get a relative path.  If the
  location
  you are calling urlFor() from changes, it will get a new location
 
  Note the only difference between the two urls is the ../../.. prefix
 
 
  On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
 
   WHen I start my application, my urlFor() returns a different URL than
  when
  I
  call it a second time?
 
ResourceReference iconref = new ResourceReference(anchorclass,
  iconname);
System.out.println(URL: +urlFor(iconref));
 
  First time it returns:
  URL:
 
 
 ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
 
  second time:
  URL:
 
 
 resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
 
  Any ideas?
 
  Thanks
  Pieter
  --
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
  --
  Pieter Claassen
  musmato.com
 
 

 --
 View this message in context:
 http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26089957.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




-- 
Pieter Claassen
musmato.com


urlFor(ResourceReference) strangeness

2009-10-27 Thread pieter claassen
WHen I start my application, my urlFor() returns a different URL than when I
call it a second time?

ResourceReference iconref = new ResourceReference(anchorclass,
iconname);
System.out.println(URL: +urlFor(iconref));

First time it returns:
URL:
../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png

second time:
URL:
resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png

Any ideas?

Thanks
Pieter
--


Re: urlFor(ResourceReference) strangeness

2009-10-27 Thread pieter claassen
Ok, but I have a panel and I want to add an Image to the panel but when I
log into my application I get the ../../.. prefix, and the ResourceReference
then fails. However, once I click on any link, the prefix disappears and
then my panel can find the ResourceReference. Am I misunderstanding how
resource references should be used?

Thanks,
Pieter

On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley ryan...@gmail.com wrote:

 urlFor( ) uses the current request to get a relative path.  If the location
 you are calling urlFor() from changes, it will get a new location

 Note the only difference between the two urls is the ../../.. prefix


 On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:

  WHen I start my application, my urlFor() returns a different URL than when
 I
 call it a second time?

   ResourceReference iconref = new ResourceReference(anchorclass,
 iconname);
   System.out.println(URL: +urlFor(iconref));

 First time it returns:
 URL:

 ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png

 second time:
 URL:

 resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png

 Any ideas?

 Thanks
 Pieter
 --



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




-- 
Pieter Claassen
musmato.com


How to reach a component in ListView

2009-10-20 Thread pieter claassen
I have an abstract class that adds a ListView to the page in the
constructor. In the constructors of my children, I would like to set some of
the rows in the ListView invisible. How do I reach the Wicket Components
that were added to a ListView from outside the Listview.

e.g.
public abstract ListDocumentsForObject{
public ListDocumentsForObject() {

ListView documents = new ListView(documents, documentlist) {

@Override
protected void populateItem(ListItem item) {
   .
Link delete = new ConfirmLink(delete) {


public final class ListDocumentsForUser extends ListDocumentsForObject {
public ListDocumentsForUser(...) {
super(...);
setAllDeleteButtonsVisible(false);   -I want to set all or some
of the delete links as invisible.


Thanks,
Pieter


Re: Spring annotations fail to inject into webmodels

2009-09-12 Thread pieter claassen
My abstract basewebmodel constructor from which all my webmodels inherit
marks inself for Spring injection but still no injection takes place. Any
suggestions where I can look?

Can I run the injection in the constructor of an abstract model from which I
inherit all my webmodels? I cannot see why not?

Thanks in advanced.
P



BaseWebModel.java
=
...
public BaseWebModel(Long id) {
this.id = id;
InjectorHolder.getInjector().inject(this);
}

here is an example of my TemplateWebModel that uses @SpringBean to set
TemplateFactory
TemplateWebModel.java
===

...
@SpringBean(name=TemplateFactory)
private TemplateFactory templateFactory;

public TemplateWebModel(Template template) {
super(template);
}



P

On Fri, Sep 11, 2009 at 10:42 AM, jWeekend jweekend_for...@cabouge.comwrote:


 Pieter,

 If you want to use Spring's @Configuarble you'll need to enable Load Time
 Weaving or Complie Time Weaving.

 To use @SpringBean with an object that is not a Wicket Component you need
 to
 InjectorHolder.getInjector().inject(this) on initialisation of your object.

 The benefit of the latter approach is that you do not need to introduce
 weaving and that Wicket will make sure you have a serialisable proxy
 injected.

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




 Pieter Claassen wrote:
 
  I am using maven, spring 2.5.6, wicket 1.4 and am trying to inject my
  DAO's
  into my wicket models but I find that Spring just ignores my advice.
 
  My question:
  1. @SpringBean only works on stuff that inherits from Component. What do
 I
  do with things like session and models that don't? I am trying to use
  @Configurable but that is being ignored.
  2. My POM deps are below. What should I pull in to have @Configurable
  working?
  3. BTW. When I comment the bean out of my XML config, then I do get an
  error
  so I am not sure if I am doing something very small wrong?
 
  Thanks.
  Pieter
 
  pom.xml
  ===
  ...
 dependency
  groupIdorg.springframework/groupId
  artifactIdspring-core/artifactId
  version${spring.version}/version
  /dependency
 
  dependency
  groupIdorg.apache.wicket/groupId
  artifactIdwicket-spring/artifactId
  version${wicket.version}/version
!--Same results whether I include or exclude the next session--
exclusions
  exclusion
groupIdorg.springframework/groupId
artifactIdspring/artifactId
  /exclusion
/exclusions
  /dependency
  
 
 
  TemplateWebModel.java
  ==
  .
  @Configurable
  public class TemplateWebModel extends AbstractDataSetWebModelTemplate {
 
  private TemplateFactory templateFactory;
 
  public TemplateFactory getTemplateFactory() {
  return templateFactory;
  }
 
  public void setTemplateFactory(TemplateFactory templateFactory) {
 throw new RuntimeException(REACHED TEMPLATE FACTORY SET); //This
  setter is never run
  //this.templateFactory = templateFactory;
  }
  .
 
  WicketApplicationDefinitition.xml
  ==
 
  ?xml version=1.0 encoding=UTF-8?
  beans xmlns=http://www.springframework.org/schema/beans;
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 xmlns:context=http://www.springframework.org/schema/context;
 xsi:schemaLocation=
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-2.5.xsd;
 
  context:annotation-config/
  !--aop:aspectj-autoproxy/--
 
  !-- a bean that supplies my primary application database client --
  bean id=appDataSource class=com.musmato.dao.ApplicationDBFactory
  destroy-method=close
  constructor-arg
  ref bean=appConfig /
  /constructor-arg
  /bean
 
  !-- a bean that supplies a network database client for template uploads
  --
  bean id=rootDataSource class=com.musmato.dao.RootDBFactory
  destroy-method=close
  constructor-arg
  ref bean=appConfig /
  /constructor-arg
  /bean
  .
  bean id=TemplateFactory class=com.musmato.dao.TemplateFactory
  property name=client ref=appDataSource /
  /bean
  
 
 
 
 
 
  --
  Pieter Claassen
  musmato.com
 
 

 --
 View this message in context:
 http://www.nabble.com/Spring-annotations-fail-to-inject-into-webmodels-tp25396625p25397205.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




-- 
Pieter

Spring annotations fail to inject into webmodels

2009-09-11 Thread pieter claassen
I am using maven, spring 2.5.6, wicket 1.4 and am trying to inject my DAO's
into my wicket models but I find that Spring just ignores my advice.

My question:
1. @SpringBean only works on stuff that inherits from Component. What do I
do with things like session and models that don't? I am trying to use
@Configurable but that is being ignored.
2. My POM deps are below. What should I pull in to have @Configurable
working?
3. BTW. When I comment the bean out of my XML config, then I do get an error
so I am not sure if I am doing something very small wrong?

Thanks.
Pieter

pom.xml
===
...
   dependency
groupIdorg.springframework/groupId
artifactIdspring-core/artifactId
version${spring.version}/version
/dependency

dependency
groupIdorg.apache.wicket/groupId
artifactIdwicket-spring/artifactId
version${wicket.version}/version
  !--Same results whether I include or exclude the next session--
  exclusions
exclusion
  groupIdorg.springframework/groupId
  artifactIdspring/artifactId
/exclusion
  /exclusions
/dependency



TemplateWebModel.java
==
.
@Configurable
public class TemplateWebModel extends AbstractDataSetWebModelTemplate {

private TemplateFactory templateFactory;

public TemplateFactory getTemplateFactory() {
return templateFactory;
}

public void setTemplateFactory(TemplateFactory templateFactory) {
   throw new RuntimeException(REACHED TEMPLATE FACTORY SET); //This
setter is never run
//this.templateFactory = templateFactory;
}
.

WicketApplicationDefinitition.xml
==

?xml version=1.0 encoding=UTF-8?
beans xmlns=http://www.springframework.org/schema/beans;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   xmlns:context=http://www.springframework.org/schema/context;
   xsi:schemaLocation=
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd;

context:annotation-config/
!--aop:aspectj-autoproxy/--

!-- a bean that supplies my primary application database client --
bean id=appDataSource class=com.musmato.dao.ApplicationDBFactory
destroy-method=close
constructor-arg
ref bean=appConfig /
/constructor-arg
/bean

!-- a bean that supplies a network database client for template uploads --
bean id=rootDataSource class=com.musmato.dao.RootDBFactory
destroy-method=close
constructor-arg
ref bean=appConfig /
/constructor-arg
/bean
.
bean id=TemplateFactory class=com.musmato.dao.TemplateFactory
property name=client ref=appDataSource /
/bean






-- 
Pieter Claassen
musmato.com


Re: log4j question with wicket

2009-07-28 Thread pieter claassen
Maarten,

a) In my source tree, it is in webapp/src/main/resources/log4j.properties.
When deployed, it ends up in WEB-INF/classes/log4j.properties
b) yes, log4j-1.2.15.jar

log4j is working fine, I can get a root logger and log to it. The problem
seems that the wicket infrastructure is using slf4j and somehow, tomcat6 is
passing its catalina.out as a root logger to log4j, rather than the log4j
root logger.

I am not a boffin on slf4j and there seems to be little documentation on how
to integrate slf4j into tomcat, rather than log4j.

I am sure there is somebody who is using tomcat, wicket and slf4j/log4j in
production?

P


On Mon, Jul 27, 2009 at 7:35 PM, Maarten Bosteels
mbosteels@gmail.comwrote:

 a) Where does the log4j.properties file for your webapp reside ?
 b) Do you have a log4j.jar in WEB-INF/lib/ ?

 M.


 On Mon, Jul 27, 2009 at 4:45 PM, pieter claassen 
 pieter.claas...@gmail.com wrote:

 I am sure something is broken in tomcat. This is not a dependency issue as
 the build runs file and manually logging info with log4j also works (see
 below). The problem seems when wicket logs using slf4j and this only goes
 to
 catalina.log (I cannot get this redirected to my own log file).

 If I understand this correctly, wicket uses slf4j to log its own
 internals.
 With tomcat6, I am supposed to then configure log4j (or any adapter that I
 want to) to get that information to the location I would like to (a local
 text log file).

 I am trying to enable wicket's requestlog debugging and directing the
 output
 to my application log file for later inspection.

 If I run the following code, I get a message in catalina.out (I also get
 all
 the debug information from wicket requestlogger on catalina.out)

 Logger logger=LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
 logger.info(AUTH PAGE ACCESSED);

 When I run the code under a debugger, I can see that logger points to
 catalina.out, so clearly I failed to point rootLogger to another file with
 either of my log4j.properties settings.

 Note however, that if I use org.apache.log4j.Logger then I can correctly
 dump logging infor to my target file

 Logger.getRootLogger().info(AUTHPAGE Logged with
 Logger.getRootLogger());

 Here is my question:

 1. What is the correct procedure to enable request logging with wicket and
 tomcat so that each of my applications dumps its request data to a
 specific
 text file?

 Thanks for all the feedback so far.
 Pieter


 here is my log4j.properties in my tomcat lib directory

 log4j.rootLogger=INFO, R
 log4j.appender.R=org.apache.log4j.RollingFileAppender
 log4j.appender.R.File=${catalina.home}/logs/tomcat.log
 log4j.appender.R.MaxFileSize=10MB
 log4j.appender.R.MaxBackupIndex=10
 log4j.appender.R.layout=org.apache.log4j.PatternLayout
 log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
 log4j.logger.org.apache.catalina=INFO, R

 log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO,
 R
 log4j.logger.org.apache.catalina.core=INFO, R
 log4j.logger.org.apache.catalina.session=INFO, R

 Here is my application log4j.properties file.

 log4j.rootLogger=INFO,R
 log4j.category.org.apache.wicket.protocol.http.RequestLogger=INFO
 log4j.logger.org.apache.wicket=INFO
 log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
 log4j.logger.org.apache.wicket.version=INFO
 log4j.logger.org.apache.wicket.RequestCycle=INFO
 log4j.appender.R=org.apache.log4j.RollingFileAppender
 log4j.appender.R.File=/var/log/${application.name}/application.log
 log4j.appender.R.MaxFileSize=10MB
 log4j.appender.R.MaxBackupIndex=10
 log4j.appender.R.layout=org.apache.log4j.PatternLayout
 log4j.appender.R.layout.ConversionPattern=%p %t %c - log file%m%n



 On Mon, Jul 27, 2009 at 12:00 PM, Maarten Bosteels
 mbosteels@gmail.comwrote:

  On Fri, Jul 24, 2009 at 3:47 PM, pieter claassen pie...@claassen.co.uk
  wrote:
 
   I think that slf4j is not working in my setup and it might have
 nothing
  to
   do with Tomcat. As a matter of fact, I assume I don't even have to
 have
   log4j or slf4j working with tomcat, but that as long as my POM
 references
   the correct dependencies, my application should log correctly?
  
   To overcome the following error, I had to upgrade by slf4j and log4j
 deps
   to
   the latest version.
  
   Caused by: java.lang.IllegalAccessError: tried to access field
   org.slf4j.impl.StaticLoggerBinder.SINGLETON from class
   org.slf4j.LoggerFactory
  
   These are my maven deps.
  
  dependency
  groupIdorg.slf4j/groupId
  artifactIdslf4j-log4j12/artifactId
  version1.5.6/version
  /dependency
  dependency
  groupIdorg.slf4j/groupId
  artifactIdslf4j-api/artifactId
  version1.5.6/version
  /dependency
 
 
  You still need log4j itself.  add this dependency:
 
 dependency
 groupIdlog4j/groupId
 artifactIdlog4j/artifactId
 version1.2.14/version

Re: log4j question with wicket

2009-07-27 Thread pieter claassen
I am sure something is broken in tomcat. This is not a dependency issue as
the build runs file and manually logging info with log4j also works (see
below). The problem seems when wicket logs using slf4j and this only goes to
catalina.log (I cannot get this redirected to my own log file).

If I understand this correctly, wicket uses slf4j to log its own internals.
With tomcat6, I am supposed to then configure log4j (or any adapter that I
want to) to get that information to the location I would like to (a local
text log file).

I am trying to enable wicket's requestlog debugging and directing the output
to my application log file for later inspection.

If I run the following code, I get a message in catalina.out (I also get all
the debug information from wicket requestlogger on catalina.out)

Logger logger=LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
logger.info(AUTH PAGE ACCESSED);

When I run the code under a debugger, I can see that logger points to
catalina.out, so clearly I failed to point rootLogger to another file with
either of my log4j.properties settings.

Note however, that if I use org.apache.log4j.Logger then I can correctly
dump logging infor to my target file

Logger.getRootLogger().info(AUTHPAGE Logged with Logger.getRootLogger());

Here is my question:

1. What is the correct procedure to enable request logging with wicket and
tomcat so that each of my applications dumps its request data to a specific
text file?

Thanks for all the feedback so far.
Pieter


here is my log4j.properties in my tomcat lib directory

log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.logger.org.apache.catalina=INFO, R
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO,
R
log4j.logger.org.apache.catalina.core=INFO, R
log4j.logger.org.apache.catalina.session=INFO, R

Here is my application log4j.properties file.

log4j.rootLogger=INFO,R
log4j.category.org.apache.wicket.protocol.http.RequestLogger=INFO
log4j.logger.org.apache.wicket=INFO
log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
log4j.logger.org.apache.wicket.version=INFO
log4j.logger.org.apache.wicket.RequestCycle=INFO
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/log/${application.name}/application.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - log file%m%n



On Mon, Jul 27, 2009 at 12:00 PM, Maarten Bosteels
mbosteels@gmail.comwrote:

 On Fri, Jul 24, 2009 at 3:47 PM, pieter claassen pie...@claassen.co.uk
 wrote:

  I think that slf4j is not working in my setup and it might have nothing
 to
  do with Tomcat. As a matter of fact, I assume I don't even have to have
  log4j or slf4j working with tomcat, but that as long as my POM references
  the correct dependencies, my application should log correctly?
 
  To overcome the following error, I had to upgrade by slf4j and log4j deps
  to
  the latest version.
 
  Caused by: java.lang.IllegalAccessError: tried to access field
  org.slf4j.impl.StaticLoggerBinder.SINGLETON from class
  org.slf4j.LoggerFactory
 
  These are my maven deps.
 
 dependency
 groupIdorg.slf4j/groupId
 artifactIdslf4j-log4j12/artifactId
 version1.5.6/version
 /dependency
 dependency
 groupIdorg.slf4j/groupId
 artifactIdslf4j-api/artifactId
 version1.5.6/version
 /dependency


 You still need log4j itself.  add this dependency:

dependency
groupIdlog4j/groupId
artifactIdlog4j/artifactId
version1.2.14/version
  /dependency

 Maarten


 
 
  I see the same behaviour in Glassfish and tomcat. Does anybody have
  slf4j-1.5.6 working with log4j-1.2.14?
 
  I am stumped?!
  P
 
 
  On Fri, Jul 24, 2009 at 9:22 AM, pieter claassen pie...@claassen.co.uk
  wrote:
 
   I am trying to get my application to log to a separate file with the
   following log4j.properties (server is tomcat6 in netbeans). I enabled
 the
   following in my wicketapplication.
  
   getRequestLoggerSettings().setRequestLoggerEnabled(true);
  
   What I find is that catalina.{date}.out logs the requests correctly,
 but
  I
   get tomcat startup info in my logfile and then nothing else.
  
   Any ideas?
  
   Thanks,
   Pieter
  
   /var/log/webapp/application.log
   
  
   2009-07-24 09:21:28,052 INFO  - ContextLoader  - Root
   WebApplicationContext: initialization started
   2009-07-24 09:21:28,082 INFO  - XmlWebApplicationContext   - Refreshing
  
 org.springframework.web.context.support.xmlwebapplicationcont

log4j question with wicket

2009-07-24 Thread pieter claassen
I am trying to get my application to log to a separate file with the
following log4j.properties (server is tomcat6 in netbeans). I enabled the
following in my wicketapplication.

getRequestLoggerSettings().setRequestLoggerEnabled(true);

What I find is that catalina.{date}.out logs the requests correctly, but I
get tomcat startup info in my logfile and then nothing else.

Any ideas?

Thanks,
Pieter

/var/log/webapp/application.log


2009-07-24 09:21:28,052 INFO  - ContextLoader  - Root
WebApplicationContext: initialization started
2009-07-24 09:21:28,082 INFO  - XmlWebApplicationContext   - Refreshing
org.springframework.web.context.support.xmlwebapplicationcont...@1077092:
display name [Root WebApplicationContext]; startup date [Fri Jul 24 09:21:28
CEST 2009]; root of context hierarchy
2009-07-24 09:21:28,134 INFO  - XmlBeanDefinitionReader- Loading XML
bean definitions from ServletContext resource
[/WEB-INF/WicketApplicationDefinition.xml]
2009-07-24 09:21:28,555 INFO  - XmlWebApplicationContext   - Bean factory
for application context
[org.springframework.web.context.support.xmlwebapplicationcont...@1077092]:
org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b
2009-07-24 09:21:28,582 INFO  - DefaultListableBeanFactory -
Pre-instantiating singletons in
org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b:
defining beans [myDataSource,appConfig,WicketApplication]; root of factory
hierarchy
2009-07-24 09:21:29,172 INFO  - ContextLoader  - Root
WebApplicationContext: initialization completed in 1120 ms


log4j.properties
==
log4j.rootLogger=INFO, file

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=100KB
log4j.appender.file.maxBackupIndex=5
log4j.appender.file.File=/var/log/${application.name}/application.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p - %-26.26c{1} - %m\n


log4j.catagory.org.apache.wicket.protocol.http.RequestLogger=INFO
log4j.logger.org.apache.wicket=INFO
log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
log4j.logger.org.apache.wicket.version=INFO
log4j.logger.org.apache.wicket.RequestCycle=INFO

-- 
Pieter Claassen


Re: log4j question with wicket

2009-07-24 Thread pieter claassen
There seems to be something broken in wicket here.

Logger.getRootLogger().info(AUTHPAGE REQUESTED);

This does log to my log file, but for some reason the following code still
just logs to the console in tomcat. I have converted tomcat to use log4j and
can print tomcat debug into to a file.

log4j.category.org.apache.wicket.protocol.http.RequestLogger=INFO

Any ideas?

Thanks,
Pieter

On Fri, Jul 24, 2009 at 9:22 AM, pieter claassen pie...@claassen.co.ukwrote:

 I am trying to get my application to log to a separate file with the
 following log4j.properties (server is tomcat6 in netbeans). I enabled the
 following in my wicketapplication.

 getRequestLoggerSettings().setRequestLoggerEnabled(true);

 What I find is that catalina.{date}.out logs the requests correctly, but I
 get tomcat startup info in my logfile and then nothing else.

 Any ideas?

 Thanks,
 Pieter

 /var/log/webapp/application.log
 

 2009-07-24 09:21:28,052 INFO  - ContextLoader  - Root
 WebApplicationContext: initialization started
 2009-07-24 09:21:28,082 INFO  - XmlWebApplicationContext   - Refreshing
 org.springframework.web.context.support.xmlwebapplicationcont...@1077092:
 display name [Root WebApplicationContext]; startup date [Fri Jul 24 09:21:28
 CEST 2009]; root of context hierarchy
 2009-07-24 09:21:28,134 INFO  - XmlBeanDefinitionReader- Loading XML
 bean definitions from ServletContext resource
 [/WEB-INF/WicketApplicationDefinition.xml]
 2009-07-24 09:21:28,555 INFO  - XmlWebApplicationContext   - Bean factory
 for application context
 [org.springframework.web.context.support.xmlwebapplicationcont...@1077092]:
 org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b
 2009-07-24 09:21:28,582 INFO  - DefaultListableBeanFactory -
 Pre-instantiating singletons in
 org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b:
 defining beans [myDataSource,appConfig,WicketApplication]; root of factory
 hierarchy
 2009-07-24 09:21:29,172 INFO  - ContextLoader  - Root
 WebApplicationContext: initialization completed in 1120 ms


 log4j.properties
 ==
 log4j.rootLogger=INFO, file

 log4j.appender.file=org.apache.log4j.RollingFileAppender
 log4j.appender.file.maxFileSize=100KB
 log4j.appender.file.maxBackupIndex=5
 log4j.appender.file.File=/var/log/${application.name}/application.log
 log4j.appender.file.layout=org.apache.log4j.PatternLayout
 log4j.appender.file.layout.ConversionPattern=%d %-5p - %-26.26c{1} - %m\n


 log4j.catagory.org.apache.wicket.protocol.http.RequestLogger=INFO
 log4j.logger.org.apache.wicket=INFO
 log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
 log4j.logger.org.apache.wicket.version=INFO
 log4j.logger.org.apache.wicket.RequestCycle=INFO

 --
 Pieter Claassen




-- 
Pieter Claassen
musmato.com


Re: log4j question with wicket

2009-07-24 Thread pieter claassen
Yes, I find that if I use log4j directly, then it works, but if I use slf4j,
then it logs via the built in java.util.logging of tomcat6. So the issue
seems to be to integrate slf4j with Tomcat6. There seems to be little out
there on how to replace commons logging with slf4j rather than log4j (so it
is either *very* easy or *very* hard)

This prints to the tomcat console but not to my log anymore.

Logger logger=LoggerFactory.getLogger(AuthPage.class);
logger.info(AUTH PAGE ACCESSED);

P

On Fri, Jul 24, 2009 at 2:13 PM, McIlwee, Craig 
craig.mcil...@openroadsconsulting.com wrote:

 I doubt this is a wicket problem, I can redirect all logging for each of my
 wars to their own file with no trouble.

 First, what slf4j implementation are you using?

 Second, have a look at this page:
 http://www.jboss.org/community/wiki/Log4jRepositorySelector.  I know that
 its for JBoss, but I image it should work for you also since JBoss is built
 on top of tomcat.  In JBoss 4.2.3 and lower I was able to use log4j sandbox
 alpha 3, which had a similar implementation of the repository selector that
 could work based on JNDI context or context classloader.  Good luck finding
 that jar though, it's damn near impossible, you may have to download from
 apache's SVN and build it yourself.  In JBoss 5+ the deployment structure
 changed and I now have to use a customized version of the class at the link
 above, works just fine.

 Craig
 Open Roads Consulting, Inc.
 757-546-3401
 http://www.openroadsconsulting.com
  _

 From: pieter claassen [mailto:pie...@claassen.co.uk]
 To: users@wicket.apache.org
 Sent: Fri, 24 Jul 2009 05:04:03 -0400
 Subject: Re: log4j question with wicket

 There seems to be something broken in wicket here.

  Logger.getRootLogger().info(AUTHPAGE REQUESTED);

  This does log to my log file, but for some reason the following code still
  just logs to the console in tomcat. I have converted tomcat to use log4j
 and
  can print tomcat debug into to a file.

  log4j.category.org.apache.wicket.protocol.http.RequestLogger=INFO

  Any ideas?

  Thanks,
  Pieter

  On Fri, Jul 24, 2009 at 9:22 AM, pieter claassen pie...@claassen.co.uk
 wrote:

   I am trying to get my application to log to a separate file with the
   following log4j.properties (server is tomcat6 in netbeans). I enabled
 the
   following in my wicketapplication.
  
   getRequestLoggerSettings().setRequestLoggerEnabled(true);
  
   What I find is that catalina.{date}.out logs the requests correctly, but
 I
   get tomcat startup info in my logfile and then nothing else.
  
   Any ideas?
  
   Thanks,
   Pieter
  
   /var/log/webapp/application.log
   
  
   2009-07-24 09:21:28,052 INFO  - ContextLoader  - Root
   WebApplicationContext: initialization started
   2009-07-24 09:21:28,082 INFO  - XmlWebApplicationContext   - Refreshing
   org.springframework.web.context.support.xmlwebapplicationcont...@1077092
 :
   display name [Root WebApplicationContext]; startup date [Fri Jul 24
 09:21:28
   CEST 2009]; root of context hierarchy
   2009-07-24 09:21:28,134 INFO  - XmlBeanDefinitionReader- Loading XML
   bean definitions from ServletContext resource
   [/WEB-INF/WicketApplicationDefinition.xml]
   2009-07-24 09:21:28,555 INFO  - XmlWebApplicationContext   - Bean
 factory
   for application context
  
 [org.springframework.web.context.support.xmlwebapplicationcont...@1077092
 ]:
  
 org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b
   2009-07-24 09:21:28,582 INFO  - DefaultListableBeanFactory -
   Pre-instantiating singletons in
  
 org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b
 :
   defining beans [myDataSource,appConfig,WicketApplication]; root of
 factory
   hierarchy
   2009-07-24 09:21:29,172 INFO  - ContextLoader  - Root
   WebApplicationContext: initialization completed in 1120 ms
  
  
   log4j.properties
   ==
   log4j.rootLogger=INFO, file
  
   log4j.appender.file=org.apache.log4j.RollingFileAppender
   log4j.appender.file.maxFileSize=100KB
   log4j.appender.file.maxBackupIndex=5
   log4j.appender.file.File=/var/log/${application.name}/application.log
   log4j.appender.file.layout=org.apache.log4j.PatternLayout
   log4j.appender.file.layout.ConversionPattern=%d %-5p - %-26.26c{1} -
 %m\n
  
  
   log4j.catagory.org.apache.wicket.protocol.http.RequestLogger=INFO
   log4j.logger.org.apache.wicket=INFO
   log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
   log4j.logger.org.apache.wicket.version=INFO
   log4j.logger.org.apache.wicket.RequestCycle=INFO
  
   --
   Pieter Claassen
  
  


  --
  Pieter Claassen
  musmato.com





-- 
Pieter Claassen
musmato.com


Re: log4j question with wicket

2009-07-24 Thread pieter claassen
I think that slf4j is not working in my setup and it might have nothing to
do with Tomcat. As a matter of fact, I assume I don't even have to have
log4j or slf4j working with tomcat, but that as long as my POM references
the correct dependencies, my application should log correctly?

To overcome the following error, I had to upgrade by slf4j and log4j deps to
the latest version.

Caused by: java.lang.IllegalAccessError: tried to access field
org.slf4j.impl.StaticLoggerBinder.SINGLETON from class
org.slf4j.LoggerFactory

These are my maven deps.

dependency
groupIdorg.slf4j/groupId
artifactIdslf4j-log4j12/artifactId
version1.5.6/version
/dependency
dependency
groupIdorg.slf4j/groupId
artifactIdslf4j-api/artifactId
version1.5.6/version
/dependency

I see the same behaviour in Glassfish and tomcat. Does anybody have
slf4j-1.5.6 working with log4j-1.2.14?

I am stumped?!
P


On Fri, Jul 24, 2009 at 9:22 AM, pieter claassen pie...@claassen.co.ukwrote:

 I am trying to get my application to log to a separate file with the
 following log4j.properties (server is tomcat6 in netbeans). I enabled the
 following in my wicketapplication.

 getRequestLoggerSettings().setRequestLoggerEnabled(true);

 What I find is that catalina.{date}.out logs the requests correctly, but I
 get tomcat startup info in my logfile and then nothing else.

 Any ideas?

 Thanks,
 Pieter

 /var/log/webapp/application.log
 

 2009-07-24 09:21:28,052 INFO  - ContextLoader  - Root
 WebApplicationContext: initialization started
 2009-07-24 09:21:28,082 INFO  - XmlWebApplicationContext   - Refreshing
 org.springframework.web.context.support.xmlwebapplicationcont...@1077092:
 display name [Root WebApplicationContext]; startup date [Fri Jul 24 09:21:28
 CEST 2009]; root of context hierarchy
 2009-07-24 09:21:28,134 INFO  - XmlBeanDefinitionReader- Loading XML
 bean definitions from ServletContext resource
 [/WEB-INF/WicketApplicationDefinition.xml]
 2009-07-24 09:21:28,555 INFO  - XmlWebApplicationContext   - Bean factory
 for application context
 [org.springframework.web.context.support.xmlwebapplicationcont...@1077092]:
 org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b
 2009-07-24 09:21:28,582 INFO  - DefaultListableBeanFactory -
 Pre-instantiating singletons in
 org.springframework.beans.factory.support.defaultlistablebeanfact...@1ab5e0b:
 defining beans [myDataSource,appConfig,WicketApplication]; root of factory
 hierarchy
 2009-07-24 09:21:29,172 INFO  - ContextLoader  - Root
 WebApplicationContext: initialization completed in 1120 ms


 log4j.properties
 ==
 log4j.rootLogger=INFO, file

 log4j.appender.file=org.apache.log4j.RollingFileAppender
 log4j.appender.file.maxFileSize=100KB
 log4j.appender.file.maxBackupIndex=5
 log4j.appender.file.File=/var/log/${application.name}/application.log
 log4j.appender.file.layout=org.apache.log4j.PatternLayout
 log4j.appender.file.layout.ConversionPattern=%d %-5p - %-26.26c{1} - %m\n


 log4j.catagory.org.apache.wicket.protocol.http.RequestLogger=INFO
 log4j.logger.org.apache.wicket=INFO
 log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
 log4j.logger.org.apache.wicket.version=INFO
 log4j.logger.org.apache.wicket.RequestCycle=INFO

 --
 Pieter Claassen




-- 
Pieter Claassen
musmato.com


redirectToInterceptPage doesn't work constructor

2009-07-23 Thread pieter claassen
What is the correct way to redirect to a login page from within a
constructor. This is wicket  1.3.5 and the code below just doesn't redirect.
All my pages inherit from AuthPage().

 public AuthPage() {
super();
add(new MainMenuPanel(mainmenu, this));
add(new FeedbackPanel(feedback));
if (getUser() == null) {
redirectToInterceptPage(new LoginPage());
} else {
authorized();
add(new UserAdminPanel(adminpanel));
}
}

-- 
Pieter Claassen
musmato.com


Re: redirectToInterceptPage doesn't work constructor

2009-07-23 Thread pieter claassen
Sorry, I sound illiterate to myself here. To start again, it seems that I
cannot get redirectToInterceptPage to work correctly in my constructor for
the AuthPage class which all my pages inherit from.

Any ideas on how to do this? I find using requestcycle's redirecTo to tell
me that I can only redirect a page once. Anyhow, I am sure that redirectTo
will not remember the redirector URL.

Thanks
Pieter

On Thu, Jul 23, 2009 at 11:36 AM, pieter claassen pie...@claassen.co.ukwrote:

 What is the correct way to redirect to a login page from within a
 constructor. This is wicket  1.3.5 and the code below just doesn't redirect.
 All my pages inherit from AuthPage().

  public AuthPage() {
 super();
 add(new MainMenuPanel(mainmenu, this));
 add(new FeedbackPanel(feedback));
 if (getUser() == null) {
 redirectToInterceptPage(new LoginPage());
 } else {
 authorized();
 add(new UserAdminPanel(adminpanel));
 }
 }

 --
 Pieter Claassen
 musmato.com




-- 
Pieter Claassen
musmato.com


Re: redirectToInterceptPage doesn't work constructor

2009-07-23 Thread pieter claassen
Thanks Martijn. This worked best:

throw new RestartResponseAtInterceptPageException(LoginPage.class);

P

On Thu, Jul 23, 2009 at 12:41 PM, Martijn Dashorst 
martijn.dasho...@gmail.com wrote:

 throw new Redirect.Exception() instead

 Martijn

 On Thu, Jul 23, 2009 at 11:44 AM, pieter claassenpie...@claassen.co.uk
 wrote:
  Sorry, I sound illiterate to myself here. To start again, it seems that I
  cannot get redirectToInterceptPage to work correctly in my constructor
 for
  the AuthPage class which all my pages inherit from.
 
  Any ideas on how to do this? I find using requestcycle's redirecTo to
 tell
  me that I can only redirect a page once. Anyhow, I am sure that
 redirectTo
  will not remember the redirector URL.
 
  Thanks
  Pieter
 
  On Thu, Jul 23, 2009 at 11:36 AM, pieter claassen pie...@claassen.co.uk
 wrote:
 
  What is the correct way to redirect to a login page from within a
  constructor. This is wicket  1.3.5 and the code below just doesn't
 redirect.
  All my pages inherit from AuthPage().
 
   public AuthPage() {
  super();
  add(new MainMenuPanel(mainmenu, this));
  add(new FeedbackPanel(feedback));
  if (getUser() == null) {
  redirectToInterceptPage(new LoginPage());
  } else {
  authorized();
  add(new UserAdminPanel(adminpanel));
  }
  }
 
  --
  Pieter Claassen
  musmato.com
 
 
 
 
  --
  Pieter Claassen
  musmato.com
 



 --
 Become a Wicket expert, learn from the best: http://wicketinaction.com
 Apache Wicket 1.3.5 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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




-- 
Pieter Claassen
musmato.com


setVisbile on form makes me reset fields

2009-07-21 Thread pieter claassen
To clear the clutter in my form, I have a number of subforms hidden behind
toggle links. However, I find that if I toggle these subforms visible using
subform.setVisble(true), then I lose my contents of the rest of the controls
on the main page.

Any tips on how to force retain the already entered data on the form when
setting subform visibility?

P


Re: setVisbile on form makes me reset fields

2009-07-21 Thread pieter claassen
Ok, here it is

private class QuestionEditForm extends Form {
private boolean questionformatter = true;
public QuestionEditForm(String id) {
super(id);
TextChunk question =
paragraphwebmodel.getEntity().getStatement();
setModel(new
CompoundPropertyModel(paragraphwebmodel));
VariableTextFieldPanel questionpanel = new
VariableTextFieldPanel(
question, new PropertyModel(paragraphwebmodel,
statement.value));
final AdvancedFormatterPanel formatquestion = new
AdvancedFormatterPanel(
formatquestion, new AdvancedFormatterWebModel(question
.getFormatter()));
add(new
DropDownChoice(clear,Arrays.asList(QuestionLayoutClearance.values()),new
MyChoiceRenderer()));
formatquestion.setVisible(false);

add(new Link(showquestionformat) {
@Override
public void onClick() {
formatquestion.setVisible(questionformatter);
if (questionformatter) {
questionformatter = false;
} else {
questionformatter = true;
}
}
});

On Tue, Jul 21, 2009 at 10:03 AM, Mathias Nilsson 
wicket.program...@gmail.com wrote:


 Can you post some code so we can see whats going on?
 --
 View this message in context:
 http://www.nabble.com/setVisbile-on-form-makes-me-reset-fields-tp2458p24583413.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




-- 
Pieter Claassen
musmato.com


setModel() and getModel() questions

2009-03-15 Thread pieter claassen
I am obviously doing something wrong here.

On my wicket pages, I am trying to set the Model with setModel()

e.g.setModel(new CompoundPropertyModel(new Treatment()));

On the components (forms, panels etc.) contained on that page, I try
to retrieve the object with getModelObject() or getInnermostModel()
but both of them return null.

eg. Treatment treatment = (Treatment) getModelObject();

The other components still function correctly in the form so they
manage to access the model properties using the CompoundPropertyModel.

What is the difference between getModelObject() and
getInnermostModel().getObject()?

Anybody have a tip on what I am doing wrong here?

Thanks,
Pieter

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



Re: Correct way to deal with serialization and casting

2009-02-13 Thread pieter claassen
Ok, feedback on my own problem. It seems that if you create a private
variable and assign an IModel to it, then access it from within the
onClick() method in a listview, that it doesn't always work. You have to
explicitly add the model to the Link constructor for this to work.

It seems that the approach below doesn't always work in wicket.

Thanks for the feedback so far.
Pieter

On Thu, Feb 12, 2009 at 11:20 PM, pieter claassen pie...@claassen.co.ukwrote:

 Just to make sure I understand this correctly.
 1. Line 2:  By storing an IModel mywebmodel that nulls the object reference
 onDetach(), on my webpage, is ok for serialiazation?
 2. Line 8: When I cast the IModel to MyObject, is there a way to make this
 more safe at compile time?
 3. Line 8: object is a database object in a field on MyObject. The fact
 that I assign a reference to it in a local variable, does that mean this
 object is going to be serialized with the page? What is actually being
 serialized (the java, the html, bytecode?)
 4. Line 9: Rather than call EditWebPage with a generic IModel and do the
 runtime cast thing, I subclassed IModel into a number of webmodels such as
 ObjectModel implements IModel. This creates more programming work but at
 least provides some type safety during compile time. Is this the recommended
 way to go or is there a better way?


 1  public class MyWebPage extends WebPage{
 2  private final IModel mywebmodel;
 3  public MyWebPage(IModel model){
 4   mywebmodel=model;
 5   setModel(new CompoundPropertyModel(mywebmodel);
 6   add(new Link(edit){
 7public void onClick(){
 8 MyObject object=(MyObject) mywebmodel.getModelObject().getChild();
 9 setResponsePage(new EditWebPage(new IModel(object)));
 10}
 11  }
 12}
 13}



How to get a reference to the holding page from a panel

2009-02-13 Thread pieter claassen
Is there a simple answer for how to get a reference from a panel to the
holding page that is available at compile time (something other than
getPage() on beforeRender())?

Thanks,
Pieter


Re: How to get a reference to the holding page from a panel

2009-02-13 Thread pieter claassen
Actually I also find that using getPage() on beforeRender() to get the page
is ok as long as do deal with any problems in case you cannot get the page.

Pieter

On Fri, Feb 13, 2009 at 6:34 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 make the panel an anonymous or inner class of the page and use MyPage.this.

 -igor

 On Fri, Feb 13, 2009 at 6:14 AM, pieter claassen pie...@claassen.co.uk
 wrote:
  Is there a simple answer for how to get a reference from a panel to the
  holding page that is available at compile time (something other than
  getPage() on beforeRender())?
 
  Thanks,
  Pieter
 

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




Listview and Link sometimes fail to get objects from DB

2009-02-12 Thread pieter claassen
Listviews with Links in them, sometimes fail to retrieve the object in the
onClick() method the first time around. When I reload the page, the code
works fine.

Here is a test. In the listview below, I load the page and in the listview
loop code, I correctly retrieve the item. Note that in the onClick() the
modelobject is null.

TEMPLATE NAME IN listview: first
TEMPLATE NAME IN onClick(): null

Reloading the page, and the problem goes away.

TEMPLATE NAME IN listview: first
TEMPLATE NAME IN onClick(): first


This is using wicket 1.3.5. and db4o 7.8. This problem is normally there
when I restart my application.

Any ideas?

Example code:

ListView templateList = new ListView(listview, ModelConverter
.getModelList(templates, TemplateWebModel.class)) {
@Override
protected void populateItem(ListItem item) {
final TemplateWebModel templatewebmodel = (TemplateWebModel)
item
.getModelObject();
System.out.println(TEMPLATE NAME IN listview: 
+ templatewebmodel.getEntity().getName());

item.setModel(new CompoundPropertyModel(templatewebmodel));
 ...
item.add(new Link(edit) {
@Override
public void onClick() {
System.out.println(TEMPLATE NAME IN onClick(): 
+ templatewebmodel.getEntity().getName());
setResponsePage(new
TemplateEditPage(templatewebmodel));
}
});
...


Re: Listview and Link sometimes fail to get objects from DB

2009-02-12 Thread pieter claassen
The value first is a field on a template, that is retrieved as one
template from the list of all templates, from a db4o database using a DAO
class.

ListTemplate templates = getTemplateFactory().getAll();

So, this list is *always* retrieved correctly. Each of the templates are
correctly backed by a database object and I can retrieve any field on any
one of them.
Each one of the template objects are wrapped in a thin wrapper where they
are converted from a heavy object (Template) to a thin webmodel
(TemplateWebModel)

List templatewebmodels = ModelConverter.getModelList(templates,
TemplateWebModel.class)

In the listview block, I set the model for each list iteration:

final TemplateWebModel templatewebmodel = (TemplateWebModel)
item.getModelObject();
item.setModel(new CompoundPropertyModel(templatewebmodel));

and when I want to access the database object, I use:

getModelObject().getEntity()

This approach works both in the listview block of code, but not in any
onClick() methods of Links that I include in the listview, just after I
started my application. The second time around, things work fine.

Is this possibly a wicket problem?

Rgrds,
Pieter



On Thu, Feb 12, 2009 at 3:06 PM, Martin Makundi 
martin.maku...@koodaripalvelut.com wrote:

 Where do you set the value first?

 **
 Martin

 2009/2/12 pieter claassen pie...@claassen.co.uk:
  Listviews with Links in them, sometimes fail to retrieve the object in
 the
  onClick() method the first time around. When I reload the page, the code
  works fine.
 
  Here is a test. In the listview below, I load the page and in the
 listview
  loop code, I correctly retrieve the item. Note that in the onClick() the
  modelobject is null.
 
  TEMPLATE NAME IN listview: first
  TEMPLATE NAME IN onClick(): null
 
  Reloading the page, and the problem goes away.
 
  TEMPLATE NAME IN listview: first
  TEMPLATE NAME IN onClick(): first
 
 
  This is using wicket 1.3.5. and db4o 7.8. This problem is normally there
  when I restart my application.
 
  Any ideas?
 
  Example code:
 
  ListView templateList = new ListView(listview, ModelConverter
 .getModelList(templates, TemplateWebModel.class)) {
 @Override
 protected void populateItem(ListItem item) {
 final TemplateWebModel templatewebmodel =
 (TemplateWebModel)
  item
 .getModelObject();
 System.out.println(TEMPLATE NAME IN listview: 
 + templatewebmodel.getEntity().getName());
 
 item.setModel(new
 CompoundPropertyModel(templatewebmodel));
  ...
 item.add(new Link(edit) {
 @Override
 public void onClick() {
 System.out.println(TEMPLATE NAME IN onClick(): 
 + templatewebmodel.getEntity().getName());
 setResponsePage(new
  TemplateEditPage(templatewebmodel));
 }
 });
  ...
 

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




Re: Listview and Link sometimes fail to get objects from DB

2009-02-12 Thread pieter claassen
Hi Igor,

Am I screwing up because I thought I did convert all my code to use only
webmodels? Maybe I still fail to understand the database-wicket integration
part.

First I get all objects from the database:

ListTemplate templates = getTemplateFactory().getAll();

But they are fat and need to be wrapped by models:

ListView templateList = new ListView(listview,
ModelConverter.getModelList(templates, TemplateWebModel.class)) {

ModelConverter.getModelList(templates, TemplateWebModel.class)) is a helper
method that converts all my objects into models.

final TemplateWebModel templatewebmodel = (TemplateWebModel)
item
.getModelObject();
item.setModel(new CompoundPropertyModel(templatewebmodel));

This is more verbose, but isn't this the same as what you just recommended?
TemplateWebModel is an implementation of IModel.

getModelObject() returns an IModel object because I convert my database
objects to webmodels before I even render the list

Debugging this problem with a debugger seems unproductive because it seems
to never be there when I debug.

P


On Thu, Feb 12, 2009 at 4:15 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 this code is very bad, you should use models so that you do not end up
 serializing your entities...

 item.setModel(new CompoundPropertyModel(  item.getmodel()  ));
...
   item.add(new Link(edit   , item.getmodel()   ) {
@Override
   public void onClick() {
   System.out.println(TEMPLATE NAME IN onClick(): 
+ getmodelobject()
 .getEntity().getName());
   setResponsePage(new
 TemplateEditPage(getmodel()   ));
   }
   });

 -igor

 On Thu, Feb 12, 2009 at 5:57 AM, pieter claassen pie...@claassen.co.uk
 wrote:
  Listviews with Links in them, sometimes fail to retrieve the object in
 the
  onClick() method the first time around. When I reload the page, the code
  works fine.
 
  Here is a test. In the listview below, I load the page and in the
 listview
  loop code, I correctly retrieve the item. Note that in the onClick() the
  modelobject is null.
 
  TEMPLATE NAME IN listview: first
  TEMPLATE NAME IN onClick(): null
 
  Reloading the page, and the problem goes away.
 
  TEMPLATE NAME IN listview: first
  TEMPLATE NAME IN onClick(): first
 
 
  This is using wicket 1.3.5. and db4o 7.8. This problem is normally there
  when I restart my application.
 
  Any ideas?
 
  Example code:
 
  ListView templateList = new ListView(listview, ModelConverter
 .getModelList(templates, TemplateWebModel.class)) {
 @Override
 protected void populateItem(ListItem item) {
 final TemplateWebModel templatewebmodel =
 (TemplateWebModel)
  item
 .getModelObject();
 System.out.println(TEMPLATE NAME IN listview: 
 + templatewebmodel.getEntity().getName());
 
 item.setModel(new
 CompoundPropertyModel(templatewebmodel));
  ...
 item.add(new Link(edit) {
 @Override
 public void onClick() {
 System.out.println(TEMPLATE NAME IN onClick(): 
 + templatewebmodel.getEntity().getName());
 setResponsePage(new
  TemplateEditPage(templatewebmodel));
 }
 });
  ...
 

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




Correct way to deal with serialization and casting

2009-02-12 Thread pieter claassen
Just to make sure I understand this correctly.
1. Line 2:  By storing an IModel mywebmodel that nulls the object reference
onDetach(), on my webpage, is ok for serialiazation?
2. Line 8: When I cast the IModel to MyObject, is there a way to make this
more safe at compile time?
3. Line 8: object is a database object in a field on MyObject. The fact that
I assign a reference to it in a local variable, does that mean this object
is going to be serialized with the page? What is actually being serialized
(the java, the html, bytecode?)
4. Line 9: Rather than call EditWebPage with a generic IModel and do the
runtime cast thing, I subclassed IModel into a number of webmodels such as
ObjectModel implements IModel. This creates more programming work but at
least provides some type safety during compile time. Is this the recommended
way to go or is there a better way?


1  public class MyWebPage extends WebPage{
2  private final IModel mywebmodel;
3  public MyWebPage(IModel model){
4   mywebmodel=model;
5   setModel(new CompoundPropertyModel(mywebmodel);
6   add(new Link(edit){
7public void onClick(){
8 MyObject object=(MyObject) mywebmodel.getModelObject().getChild();
9 setResponsePage(new EditWebPage(new IModel(object)));
10}
11  }
12}
13}


How to place form in own public class for extending

2009-02-11 Thread pieter claassen
I am trying to move a form from an inner class that extends Form to a public
class. This is so that I can override the onSubmit() method of my form.

Below are my files.

When I add the form to a wicket page with

add(new TemplateEditForm(templateeditform, templatemodel));

and the corresponding html code

form wicket:id=templateeditformeditform/form

My wicket code doesn't pick the wicket:ids in the TemplateEditForm.html file
up

WicketMessage: The component(s) below failed to render. A common
problem is that you have added a component in code but forgot to
reference it in the markup (thus the component will never be
rendered).

1. [MarkupContainer [Component id = name]]
2. [MarkupContainer [Component id = version]]
3. [MarkupContainer [Component id = author]]
4. [MarkupContainer [Component id = active]]
5. [MarkupContainer [Component id = description]]
6. [MarkupContainer [Component id = textarea]]
7. [MarkupContainer [Component id = type]]
8. [MarkupContainer [Component id = submit]]

I am sure I am doing something stupid, but I cannot find the solution to
this. Any ideas?

=

public class TemplateEditForm extends Form {

private TemplateWebModel templatemodel;

public TemplateEditForm(String id, TemplateWebModel templatemodel) {
super(id);
this.templatemodel = templatemodel;
setModel(new CompoundPropertyModel(templatemodel));
add(new RequiredTextField(name));
add(new RequiredTextField(version, java.lang.Long.class));
add(new RequiredTextField(author));
add(new CheckBox(active));
add(new VariableTextFieldPanel(description, new PropertyModel(
templatemodel.getObject(), description)));
DropDownChoice ddc = new DropDownChoice(type, Arrays
.asList(TemplateType.values()), new IChoiceRenderer() {

public Object getDisplayValue(Object object) {
return getString(object.toString());
}

public String getIdValue(Object object, int index) {
return object.toString();
}

});
ddc.setRequired(true);
add(ddc);
add(new Button(submit, new ResourceModel(submit)));

}

@Override
public void onSubmit() {
WicketApplication.get().getTemplateFactory().store(
templatemodel.getEntity());
setResponsePage(new TemplateListPage());
}
}

And the corresponding html code

===


wicket:extend
table
tr
tdwicket:message key=name //td
tdinput wicket:id=name //td
/tr
tr
tdwicket:message key=version //td
tdinput wicket:id=version //td
/tr
tr
tdwicket:message key=author //td
tdinput wicket:id=author //td
/tr
tr
tdwicket:message key=active //td
tdinput type=checkbox wicket:id=active //td
/tr
tr
tdwicket:message key=description //td
tdspan wicket:id=description/span/td
/tr
tr
tdwicket:message key=type //td
tdselect wicket:id=type
option/option
/select/td
/tr

tr
td colspan=2input wicket:id=submit type=submit/td
/tr
/table
/wicket:extend


Re: How to place form in own public class for extending

2009-02-11 Thread pieter claassen
But how do you then extend the form in the panel and more importantly, how
do you override the onSubmit() method of that form?

Cheers,
Pieter

On Wed, Feb 11, 2009 at 3:50 PM, Ryan Gravener r...@ryangravener.comwrote:

 I usually make a panel, add the form to the panel and write up the form in
 the panel's markup.


 http://wicketstuff.org/wicket13/signin/?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignIn

 Ryan Gravener
 http://ryangravener.com/flex | http://twitter.com/ryangravener


 On Wed, Feb 11, 2009 at 9:40 AM, pieter claassen pie...@claassen.co.uk
 wrote:

  I am trying to move a form from an inner class that extends Form to a
  public
  class. This is so that I can override the onSubmit() method of my form.
 
  Below are my files.
 
  When I add the form to a wicket page with
 
  add(new TemplateEditForm(templateeditform, templatemodel));
 
  and the corresponding html code
 
  form wicket:id=templateeditformeditform/form
 
  My wicket code doesn't pick the wicket:ids in the TemplateEditForm.html
  file
  up
 
  WicketMessage: The component(s) below failed to render. A common
  problem is that you have added a component in code but forgot to
  reference it in the markup (thus the component will never be
  rendered).
 
  1. [MarkupContainer [Component id = name]]
  2. [MarkupContainer [Component id = version]]
  3. [MarkupContainer [Component id = author]]
  4. [MarkupContainer [Component id = active]]
  5. [MarkupContainer [Component id = description]]
  6. [MarkupContainer [Component id = textarea]]
  7. [MarkupContainer [Component id = type]]
  8. [MarkupContainer [Component id = submit]]
 
  I am sure I am doing something stupid, but I cannot find the solution to
  this. Any ideas?
 
  =
 
  public class TemplateEditForm extends Form {
 
 private TemplateWebModel templatemodel;
 
 public TemplateEditForm(String id, TemplateWebModel templatemodel) {
 super(id);
 this.templatemodel = templatemodel;
 setModel(new CompoundPropertyModel(templatemodel));
 add(new RequiredTextField(name));
 add(new RequiredTextField(version, java.lang.Long.class));
 add(new RequiredTextField(author));
 add(new CheckBox(active));
 add(new VariableTextFieldPanel(description, new PropertyModel(
 templatemodel.getObject(), description)));
 DropDownChoice ddc = new DropDownChoice(type, Arrays
 .asList(TemplateType.values()), new IChoiceRenderer() {
 
 public Object getDisplayValue(Object object) {
 return getString(object.toString());
 }
 
 public String getIdValue(Object object, int index) {
 return object.toString();
 }
 
 });
 ddc.setRequired(true);
 add(ddc);
 add(new Button(submit, new ResourceModel(submit)));
 
 }
 
 @Override
 public void onSubmit() {
 WicketApplication.get().getTemplateFactory().store(
 templatemodel.getEntity());
 setResponsePage(new TemplateListPage());
 }
  }
 
  And the corresponding html code
 
  ===
 
 
  wicket:extend
 table
 tr
 tdwicket:message key=name //td
 tdinput wicket:id=name //td
 /tr
 tr
 tdwicket:message key=version //td
 tdinput wicket:id=version //td
 /tr
 tr
 tdwicket:message key=author //td
 tdinput wicket:id=author //td
 /tr
 tr
 tdwicket:message key=active //td
 tdinput type=checkbox wicket:id=active //td
 /tr
 tr
 tdwicket:message key=description //td
 tdspan wicket:id=description/span/td
 /tr
 tr
 tdwicket:message key=type //td
 tdselect wicket:id=type
 option/option
 /select/td
 /tr
 
 tr
 td colspan=2input wicket:id=submit type=submit/td
 /tr
 /table
  /wicket:extend
 



Re: How to place form in own public class for extending

2009-02-11 Thread pieter claassen
What if you want to reuse the inner class form in another page (you have to
make it public and non-inner for visibility) and then you want to override
the onSubmit() method. If I just create a public class MyForm and stick the
form contents (minus the form tags) in MyForm.html, then wicket cannot
find any wicket variables on the form (see first post).

If you encapsulate the form in a panel, then the only problem is that you
cannot get to the onSubmit() method of the form (but if you delegate all the
work to a public method on the panel, then you can override that). Not so
pretty.

This is a bit of a corner case, but the fact is that forms are not readily
accessible wicket objects like panels and pages ( you cannot easily extend
your own publically accessible forms) or am I missing something?

Pieter

On Wed, Feb 11, 2009 at 4:28 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 what is the problem of having the form as an inner class?

 public class mypage extends webpage {

  private class myform extends form {
  ...
  }

   public mypage() {
   add(new myform(..) { protected void onsubmit() {...}});
   }
 }

 -igor

 On Wed, Feb 11, 2009 at 6:40 AM, pieter claassen pie...@claassen.co.uk
 wrote:
  I am trying to move a form from an inner class that extends Form to a
 public
  class. This is so that I can override the onSubmit() method of my form.
 
  Below are my files.
 
  When I add the form to a wicket page with
 
  add(new TemplateEditForm(templateeditform, templatemodel));
 
  and the corresponding html code
 
  form wicket:id=templateeditformeditform/form
 
  My wicket code doesn't pick the wicket:ids in the TemplateEditForm.html
 file
  up
 
  WicketMessage: The component(s) below failed to render. A common
  problem is that you have added a component in code but forgot to
  reference it in the markup (thus the component will never be
  rendered).
 
  1. [MarkupContainer [Component id = name]]
  2. [MarkupContainer [Component id = version]]
  3. [MarkupContainer [Component id = author]]
  4. [MarkupContainer [Component id = active]]
  5. [MarkupContainer [Component id = description]]
  6. [MarkupContainer [Component id = textarea]]
  7. [MarkupContainer [Component id = type]]
  8. [MarkupContainer [Component id = submit]]
 
  I am sure I am doing something stupid, but I cannot find the solution to
  this. Any ideas?
 
  =
 
  public class TemplateEditForm extends Form {
 
 private TemplateWebModel templatemodel;
 
 public TemplateEditForm(String id, TemplateWebModel templatemodel) {
 super(id);
 this.templatemodel = templatemodel;
 setModel(new CompoundPropertyModel(templatemodel));
 add(new RequiredTextField(name));
 add(new RequiredTextField(version, java.lang.Long.class));
 add(new RequiredTextField(author));
 add(new CheckBox(active));
 add(new VariableTextFieldPanel(description, new PropertyModel(
 templatemodel.getObject(), description)));
 DropDownChoice ddc = new DropDownChoice(type, Arrays
 .asList(TemplateType.values()), new IChoiceRenderer() {
 
 public Object getDisplayValue(Object object) {
 return getString(object.toString());
 }
 
 public String getIdValue(Object object, int index) {
 return object.toString();
 }
 
 });
 ddc.setRequired(true);
 add(ddc);
 add(new Button(submit, new ResourceModel(submit)));
 
 }
 
 @Override
 public void onSubmit() {
 WicketApplication.get().getTemplateFactory().store(
 templatemodel.getEntity());
 setResponsePage(new TemplateListPage());
 }
  }
 
  And the corresponding html code
 
  ===
 
 
  wicket:extend
 table
 tr
 tdwicket:message key=name //td
 tdinput wicket:id=name //td
 /tr
 tr
 tdwicket:message key=version //td
 tdinput wicket:id=version //td
 /tr
 tr
 tdwicket:message key=author //td
 tdinput wicket:id=author //td
 /tr
 tr
 tdwicket:message key=active //td
 tdinput type=checkbox wicket:id=active //td
 /tr
 tr
 tdwicket:message key=description //td
 tdspan wicket:id=description/span/td
 /tr
 tr
 tdwicket:message key=type //td
 tdselect wicket:id=type
 option/option
 /select/td
 /tr
 
 tr
 td colspan=2input wicket:id=submit type=submit/td
 /tr
 /table
  /wicket:extend
 

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




Re: Duplicate objects in db4o with back button

2009-01-23 Thread pieter claassen
Igor, thanks for your comments so far.

After a lot of struggle, I now have the following strategy in place which
just provides me with the old results, duplicate data in the database when I
add a template, and then press the back button and add it again.

Here is an example of how I create a new object in wicket (when I need a
transient model). I am trying to understand how wicket gets/sets the
objects. Any pointers?

public class TemplateAddPage extends AuthPage {
public TemplateAddPage() {
setModel(new CompoundPropertyModel(new Template()));
add(new TemplateAddForm(templateaddform));
}

@Override
public Role[] getAllowedRoles() {
return new Role[] { Role.ADMIN, Role.THERAPIST };
}

private class TemplateAddForm extends Form {
public TemplateAddForm(String id) {
super(id);
add(new RequiredTextField(name));
add(new RequiredTextField(version));
add(new RequiredTextField(author));
add(new TextArea(description));
add(new TemplateDropDownChoicePanel(ddcpanel));
}

@Override
public void onSubmit() {
Template template = (Template) getInnermostModel().getObject();
WicketApplication.get().getTemplateFactory().store(template);
setResponsePage(new TemplateListPage());
}
}
}


And here is my base IModel class

public abstract class BaseWebModelT implements IModel {

private static final long serialVersionUID = 1L;

protected Long id = null;
protected T object = null;

public abstract ClassT getBaseClass();

public abstract BaseFactoryT getFactory();

public BaseWebModel(T object) {
this.id = getFactory().getID(object);
this.object = object;
}

public T getObject() {
if (object == null) {
object = getFactory().getById(id);
if (object == null) {
throw new RuntimeException(Object not found);
}
}
return object;

}

public void setObject(Object object) {
getFactory().store((T) object);
}

public void detach() {
if (object != null) {
if (id != null) {
id = getFactory().getID(object);
object = null;
}
}
}




On Thu, Jan 22, 2009 at 7:58 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 when you click the back button you go to a previous version of the
 page (a snapshot as it existed when rendered). in that version the id
 inside the model is still null.

 -igor

 On Thu, Jan 22, 2009 at 10:48 AM, pieter claassen
 pieter.claas...@gmail.com wrote:
  Thanks for both responses. I can see what I am supposed to do, what I
 don't
  understand is what is going wrong.
 
  Why when I click on the back button, does the id of my object become
  invalid? Any pointers in the wicket docs to understand this better?
 
  Regards,
  Pieter
 
  BTW Thanks for a great framework.
 
 
  On Thu, Jan 22, 2009 at 5:44 PM, Igor Vaynberg igor.vaynb...@gmail.com
 wrote:
 
  http://wicketinaction.com/2008/09/building-a-smart-entitymodel/
 
  notice the deatch() implementation
 
  -igor
 
  On Thu, Jan 22, 2009 at 8:05 AM, pieter claassen pie...@claassen.co.uk
 
  wrote:
   I am using wicket 1.3.5 and db4o 7.4.63.11890.
  
   My objects are being passed between pages using a subclass of
   LoadableDetachableModel (see below)
  
   My problem is:
   1. I edit an object on PageA
   2. I use the back button and then re-submit the form I edited and now
 I
  have
   two objects in the database.
  
   Any ideas on why this is happening?
  
   Cheers,
   Pieter
  
  
   package com.musmato.wicket.model;
  
   import org.apache.wicket.model.LoadableDetachableModel;
  
   import com.musmato.dao.BaseFactory;
  
   public abstract class BaseWebModelT extends LoadableDetachableModel
 {
  
  private static final long serialVersionUID = 1L;
  
  protected Long id;
  
  public abstract ClassT getBaseClass();
  
  public abstract BaseFactoryT getFactory();
  
  public BaseWebModel(Long id) {
  this.id = id;
  }
  
  public BaseWebModel(T object) {
  this.id = getFactory().getID(object);
  }
  
  @Override
  protected Object load() {
  
  if (id == null) {
  return getFactory().getNewObject();
  }
  
  return getFactory().getById(id);
  }
  
   }
  
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 



Duplicate objects in db4o with back button

2009-01-22 Thread pieter claassen
I am using wicket 1.3.5 and db4o 7.4.63.11890.

My objects are being passed between pages using a subclass of
LoadableDetachableModel (see below)

My problem is:
1. I edit an object on PageA
2. I use the back button and then re-submit the form I edited and now I have
two objects in the database.

Any ideas on why this is happening?

Cheers,
Pieter


package com.musmato.wicket.model;

import org.apache.wicket.model.LoadableDetachableModel;

import com.musmato.dao.BaseFactory;

public abstract class BaseWebModelT extends LoadableDetachableModel {

private static final long serialVersionUID = 1L;

protected Long id;

public abstract ClassT getBaseClass();

public abstract BaseFactoryT getFactory();

public BaseWebModel(Long id) {
this.id = id;
}

public BaseWebModel(T object) {
this.id = getFactory().getID(object);
}

@Override
protected Object load() {

if (id == null) {
return getFactory().getNewObject();
}

return getFactory().getById(id);
}

}


Re: Duplicate objects in db4o with back button

2009-01-22 Thread pieter claassen
Thanks for both responses. I can see what I am supposed to do, what I don't
understand is what is going wrong.

Why when I click on the back button, does the id of my object become
invalid? Any pointers in the wicket docs to understand this better?

Regards,
Pieter

BTW Thanks for a great framework.


On Thu, Jan 22, 2009 at 5:44 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 http://wicketinaction.com/2008/09/building-a-smart-entitymodel/

 notice the deatch() implementation

 -igor

 On Thu, Jan 22, 2009 at 8:05 AM, pieter claassen pie...@claassen.co.uk
 wrote:
  I am using wicket 1.3.5 and db4o 7.4.63.11890.
 
  My objects are being passed between pages using a subclass of
  LoadableDetachableModel (see below)
 
  My problem is:
  1. I edit an object on PageA
  2. I use the back button and then re-submit the form I edited and now I
 have
  two objects in the database.
 
  Any ideas on why this is happening?
 
  Cheers,
  Pieter
 
 
  package com.musmato.wicket.model;
 
  import org.apache.wicket.model.LoadableDetachableModel;
 
  import com.musmato.dao.BaseFactory;
 
  public abstract class BaseWebModelT extends LoadableDetachableModel {
 
 private static final long serialVersionUID = 1L;
 
 protected Long id;
 
 public abstract ClassT getBaseClass();
 
 public abstract BaseFactoryT getFactory();
 
 public BaseWebModel(Long id) {
 this.id = id;
 }
 
 public BaseWebModel(T object) {
 this.id = getFactory().getID(object);
 }
 
 @Override
 protected Object load() {
 
 if (id == null) {
 return getFactory().getNewObject();
 }
 
 return getFactory().getById(id);
 }
 
  }
 

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




Re: How to determine which page I am on?

2008-12-17 Thread pieter claassen
Adriano, that worked, thanks!!

Why did it work?

Cheers,
Pieter


On Wed, Dec 17, 2008 at 12:11 AM, Adriano dos Santos Fernandes 
adrian...@uol.com.br wrote:

 pieter claassen wrote:

 I am trying to write a menu that formats the link nicely for the page I am
 on. So far, the novomatic tut helped the most, but there is no detail on
 how
 to customize the implementation.

 My strategy is to determine which page I am on and then to set an
 attribute
 on the link and format it with css.

 I have tried to use getParent() and getPage() on my menu panel with no
 luck.

 public class MainMenu extends Panel {
 .
if (getPage().getClass().equals(com.musmato.HomePage.class)) {
System.out.println(Homepage);
}


 I think if you put that code on onBeforeRender it will work.


 Adriano


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




How to determine which page I am on?

2008-12-16 Thread pieter claassen
I am trying to write a menu that formats the link nicely for the page I am
on. So far, the novomatic tut helped the most, but there is no detail on how
to customize the implementation.

My strategy is to determine which page I am on and then to set an attribute
on the link and format it with css.

I have tried to use getParent() and getPage() on my menu panel with no luck.

public class MainMenu extends Panel {
.
if (getPage().getClass().equals(com.musmato.HomePage.class)) {
System.out.println(Homepage);
}



ERROR - RequestCycle   - Can't instantiate page using
constructor public com.musmato.HomePage(org.apache.wicket.PageParameters)
and argument
org.apache.wicket.WicketRuntimeException: Can't instantiate page using
constructor public com.musmato.HomePage(org.apache.wicket.PageParameters)
and argument
at
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:168)
at
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:66)
at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:262)
at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:283)
at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:210)
at
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1171)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1248)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1349)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:387)
at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:199)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:864)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:533)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:207)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:147)
... 28 more
Caused by: java.lang.IllegalStateException: No Page found for component
[MarkupContainer [Component id = mainmenu, page = No Page, path =
mainmenu.MainMenu]]
at org.apache.wicket.Component.getPage(Component.java:1659)
at com.musmato.navigation.MainMenu.init(MainMenu.java:36)
at com.musmato.MyWebPage.init(MyWebPage.java:16)
at com.musmato.HomePage.init(HomePage.java:14)
... 33 more

Any help is appreciated.

Regards,
Pieter


Javadoc for wicket 1.3.5 - how to include it in eclipse

2008-10-31 Thread pieter claassen
What is the most effective way to get the documentation available offline
for wicket 1.3.5 in Eclipse. I notice that mvn eclipse:eclipse
-Ddownloadsources=true does not give javadocs.

Regards,
Pieter


ListView broken?

2008-10-23 Thread pieter claassen

I am getting a classcast exception in ListView that is stumping me.

This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:  
[MarkupContainer [Component id = questioneditform]]


Root cause:

java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
at  
org 
.apache 
.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)

at org.apache.wicket.Component.getModelObject(Component.java:1558)
at com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm 
$1.populateItem(TemplateEditPage.java:93)



This is the code that generates my ListItems:

ListView questions = new ListView(questions, template
.getQuestions()) {


@Override
protected void populateItem(ListItem item) {
final QuestionAndAnswer qanda = 
(QuestionAndAnswer) item
.getModelObject();
setModel(new 
CompoundPropertyModel(qanda));



I know for a fact that template.getQuestions() produces an ArrayList.

The arraylist works when there is only 1 item in it but when I have  
more than 1 item, it fails with the ClassCastException. Is this a  
wicket problem or am I doing something wrong?


Regards,
Pieter
pieter claassen
[EMAIL PROTECTED]




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



Re: ListView broken?

2008-10-23 Thread pieter claassen

Comments inline:

On Oct 23, 2008, at 10:59 AM, Serkan Camurcuoglu wrote:



it seems like template.getQuestions() returns a model which has a
QuestionAndAnswer instance instead of a list as its model object..



This is the code in template that returns an arraylist.

public ArrayListQuestionAndAnswer getQuestions() {
return questions;
}

Is this correct?

P



The code
on the line where the exception is thrown is:

return ((List)listView.getModelObject()).get(index);

which indicates that your problem is trying to cast a  
QuestionAndAnswer
instance to a List. Everyone is using ListView and it cannot be  
broken this

way :)




Pieter Claassen wrote:


I am getting a classcast exception in ListView that is stumping me.

This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:
[MarkupContainer [Component id = questioneditform]]

Root cause:

java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
at
org
.apache
.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java: 
55)

at org.apache.wicket.Component.getModelObject(Component.java:1558)
at com.musmato.wicket.pages.templates.TemplateEditPage 
$QuestionEditForm

$1.populateItem(TemplateEditPage.java:93)


This is the code that generates my ListItems:

ListView questions = new ListView(questions, template
.getQuestions()) {


@Override
protected void populateItem(ListItem item) {
final QuestionAndAnswer qanda = 
(QuestionAndAnswer) item
.getModelObject();
setModel(new 
CompoundPropertyModel(qanda));



I know for a fact that template.getQuestions() produces an ArrayList.

The arraylist works when there is only 1 item in it but when I have
more than 1 item, it fails with the ClassCastException. Is this a
wicket problem or am I doing something wrong?

Regards,
Pieter
pieter claassen
[EMAIL PROTECTED]




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





--
View this message in context: 
http://www.nabble.com/ListView-broken--tp20126952p20127126.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]



pieter claassen
[EMAIL PROTECTED]




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



Re: ListView broken?

2008-10-23 Thread pieter claassen

Hi Dipu,

I tried that but when I do the following:

protected void populateItem(ListItem item) {
			System.out.println(+++ +  
item.getModelObject().getClass().getName());
			final QuestionAndAnswer qanda = (QuestionAndAnswer)  
item.getModelObject();


I find that I now get the ClassCastException in the System.out.println  
line. It is clear as mud that the problem is that I am trying to force  
something into a list which is not a list?


Regards,
Pieter


On Oct 23, 2008, at 10:59 AM, Dipu wrote:

looks like template.getQuestions() is returning a list  with items  
in it

which is not of the type QuestionAndAnswer

try iterating through the list and logging the class name of each  
item in it


Dipu



On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen [EMAIL PROTECTED] 
wrote:



I am getting a classcast exception in ListView that is stumping me.

This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:
[MarkupContainer [Component id = questioneditform]]

Root cause:

java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
at
org 
.apache 
.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java: 
55)

at org.apache.wicket.Component.getModelObject(Component.java:1558)
at
com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm 
$1.populateItem(TemplateEditPage.java:93)



This is the code that generates my ListItems:

  ListView questions = new ListView(questions,
template
  .getQuestions()) {


  @Override
  protected void populateItem(ListItem  
item) {

  final QuestionAndAnswer qanda =
(QuestionAndAnswer) item
  .getModelObject 
();

  setModel(new
CompoundPropertyModel(qanda));



I know for a fact that template.getQuestions() produces an ArrayList.

The arraylist works when there is only 1 item in it but when I have  
more
than 1 item, it fails with the ClassCastException. Is this a wicket  
problem

or am I doing something wrong?

Regards,
Pieter
pieter claassen
[EMAIL PROTECTED]




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




pieter claassen
[EMAIL PROTECTED]




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



Re: ListView broken?

2008-10-23 Thread pieter claassen

Ok, I added;

public class Debug {
public static void debug(List list) {
for (Object item : list) {
System.out.println(++DEBUG++:  + 
item.getClass().toString());
}
}


and called debug just before I returned my ArrayList of question:

public ArrayListQuestionAndAnswer getQuestions() {
Debug.debug(questions);
return questions;
}

This is what I saw in my console. There are two objects in the list  
and they are both QuestionAndAnswer objects



++DEBUG++: class com.musmato.model.QuestionAndAnswer
++DEBUG++: class com.musmato.model.QuestionAndAnswer

Regards,
Pieter

On Oct 23, 2008, at 11:18 AM, Dipu wrote:

can't you check what exactly is being returned by  
template.getQuestions()

and if its a list what are the items in it




On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen [EMAIL PROTECTED] 
wrote:



Hi Dipu,

I tried that but when I do the following:

  protected void populateItem(ListItem item) {
  System.out.println(+++ +
item.getModelObject().getClass().getName());
  final QuestionAndAnswer qanda =  
(QuestionAndAnswer)

item.getModelObject();

I find that I now get the ClassCastException in the  
System.out.println
line. It is clear as mud that the problem is that I am trying to  
force

something into a list which is not a list?

Regards,
Pieter



On Oct 23, 2008, at 10:59 AM, Dipu wrote:

looks like template.getQuestions() is returning a list  with items  
in it

which is not of the type QuestionAndAnswer

try iterating through the list and logging the class name of each  
item in

it

Dipu



On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen [EMAIL PROTECTED]

wrote:


I am getting a classcast exception in ListView that is stumping me.


This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:
[MarkupContainer [Component id = questioneditform]]

Root cause:

java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
at

org 
.apache 
.wicket 
.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)

at org.apache.wicket.Component.getModelObject(Component.java:1558)
at

com.musmato.wicket.pages.templates.TemplateEditPage 
$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)



This is the code that generates my ListItems:

ListView questions = new ListView(questions,
template
.getQuestions()) {


@Override
protected void populateItem(ListItem  
item) {

final QuestionAndAnswer qanda =
(QuestionAndAnswer) item
.getModelObject 
();

setModel(new
CompoundPropertyModel(qanda));



I know for a fact that template.getQuestions() produces an  
ArrayList.


The arraylist works when there is only 1 item in it but when I  
have more

than 1 item, it fails with the ClassCastException. Is this a wicket
problem
or am I doing something wrong?

Regards,
Pieter
pieter claassen
[EMAIL PROTECTED]




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




pieter claassen
[EMAIL PROTECTED]




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




pieter claassen
[EMAIL PROTECTED]




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



Re: ListView broken?

2008-10-23 Thread pieter claassen
() {

template.delQuestion(qanda);
setResponsePage(new 
TemplateEditPage(
new 
TemplateWebModel(template)));
}
});
}
};
add(questionlist);
}

@Override
public void onSubmit() {

WicketApplication.get().getTemplateFactory().store(template);
			setResponsePage(new TemplateEditPage(new  
TemplateWebModel(template)));

}
}
}

On Oct 23, 2008, at 12:04 PM, Martijn Dashorst wrote:


The classcastexception happens on retrieving the N-th item from the
list. The class cast tries to cast the model object of the listview to
a List. Apparently the argument to the listview is not a List, but
somethign that returns a QuestionAndAnswer.

Are you looking at the correct ListView (i.e. are there more ListView
s on your page)?

Martijn

On Thu, Oct 23, 2008 at 11:55 AM, Dipu [EMAIL PROTECTED]  
wrote:

pass , sorry i have no clue

On Thu, Oct 23, 2008 at 10:37 AM, pieter claassen [EMAIL PROTECTED] 
wrote:



Ok, I added;

public class Debug {
  public static void debug(List list) {
  for (Object item : list) {
  System.out.println(++DEBUG++:  +
item.getClass().toString());
  }
  }


and called debug just before I returned my ArrayList of question:

  public ArrayListQuestionAndAnswer getQuestions() {
  Debug.debug(questions);
  return questions;
  }

This is what I saw in my console. There are two objects in the  
list and

they are both QuestionAndAnswer objects


++DEBUG++: class com.musmato.model.QuestionAndAnswer
++DEBUG++: class com.musmato.model.QuestionAndAnswer

Regards,
Pieter


On Oct 23, 2008, at 11:18 AM, Dipu wrote:

can't you check what exactly is being returned by  
template.getQuestions()

and if its a list what are the items in it




On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen [EMAIL PROTECTED]

wrote:


Hi Dipu,


I tried that but when I do the following:

protected void populateItem(ListItem item) {
System.out.println(+++ +
item.getModelObject().getClass().getName());
final QuestionAndAnswer qanda =  
(QuestionAndAnswer)

item.getModelObject();

I find that I now get the ClassCastException in the  
System.out.println
line. It is clear as mud that the problem is that I am trying to  
force

something into a list which is not a list?

Regards,
Pieter



On Oct 23, 2008, at 10:59 AM, Dipu wrote:

looks like template.getQuestions() is returning a list  with  
items in it



which is not of the type QuestionAndAnswer

try iterating through the list and logging the class name of  
each item

in
it

Dipu



On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen [EMAIL PROTECTED]


wrote:



I am getting a classcast exception in ListView that is stumping  
me.




This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:
[MarkupContainer [Component id = questioneditform]]

Root cause:

java.lang.ClassCastException:  
com.musmato.model.QuestionAndAnswer

at


org 
.apache 
.wicket 
.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
at org.apache.wicket.Component.getModelObject(Component.java: 
1558)

at


com.musmato.wicket.pages.templates.TemplateEditPage 
$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)



This is the code that generates my ListItems:

  ListView questions = new ListView(questions,
template
  .getQuestions()) {


  @Override
  protected void populateItem(ListItem  
item) {
  final QuestionAndAnswer  
qanda =

(QuestionAndAnswer) item
  .getModelObject 
();

  setModel(new
CompoundPropertyModel(qanda));



I know for a fact that template.getQuestions() produces an  
ArrayList.


The arraylist works when there is only 1 item in it but when I  
have

more
than 1 item, it fails with the ClassCastException. Is this a  
wicket

problem
or am I doing something wrong?

Regards,
Pieter
pieter claassen
[EMAIL PROTECTED]




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



pieter claassen

[EMAIL PROTECTED]




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




pieter claassen
[EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL

Re: ListView broken?

2008-10-23 Thread pieter claassen

Guys, thanks for all your feedback. You were right.

Cheers,
Pieter

On Oct 23, 2008, at 2:44 PM, Jeremy Thomerson wrote:


Johan nailed it... here are your bad lines:

  System.out.println(
item.getModelObject().getClass().getName());
  final QuestionAndAnswer qanda = (QuestionAndAnswer)
item.getModelObject();
  setModel(new CompoundPropertyModel(qanda));

That should just be changed to:

  item.setModel(new CompoundPropertyModel(item.getModel());

if that's what you want.

--  
Jeremy Thomerson

http://www.wickettraining.com

On Thu, Oct 23, 2008 at 6:13 AM, Johan Compagner  
[EMAIL PROTECTED]wrote:



What are you doing there?
You get a model object from the listitem
And then you are calling setmodel(compound) on the listview itself?
Why is that then you are changing the model of the listview inside  
the

loop that it goes over them creating listitems!

On 10/23/08, pieter claassen [EMAIL PROTECTED] wrote:

I am getting a classcast exception in ListView that is stumping me.

This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:
[MarkupContainer [Component id = questioneditform]]

Root cause:

java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
at
org
.apache
.wicket 
.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)

at org.apache.wicket.Component.getModelObject(Component.java:1558)
at com.musmato.wicket.pages.templates.TemplateEditPage 
$QuestionEditForm

$1.populateItem(TemplateEditPage.java:93)


This is the code that generates my ListItems:

 ListView questions = new ListView(questions,

template

 .getQuestions()) {


 @Override
 protected void populateItem(ListItem  
item)

{

 final QuestionAndAnswer qanda =

(QuestionAndAnswer) item
 .getModelObject 
();

 setModel(new

CompoundPropertyModel(qanda));




I know for a fact that template.getQuestions() produces an  
ArrayList.


The arraylist works when there is only 1 item in it but when I have
more than 1 item, it fails with the ClassCastException. Is this a
wicket problem or am I doing something wrong?

Regards,
Pieter
pieter claassen
[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]




pieter claassen
[EMAIL PROTECTED]




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