Re: CSS bundles order does not seem stable when using an application

2013-03-18 Thread Sylvain Vieujot
The PriorityHeaderItem solved the problem.

Thank you !

On Mon, 2013-03-18 at 05:49 -0700, armandoxxx wrote:

 read this about resources:  resources management
 http://wicketinaction.com/2012/07/wicket-6-resource-management/  
 
 us PriorityHeaderItem() 
 
 Regards
 
 Armando
 
 
 
 
 
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/CSS-bundles-order-does-not-seem-stable-when-using-an-application-tp4657299p4657319.html
 Sent from the Users forum mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


CSS bundles order does not seem stable when using an application

2013-03-17 Thread Sylvain Vieujot
My application is using a resourceBundle to concatenate CSS resources
via : getResourceBundles().addCssBundle( ... ).

My base wicket page, from which all others pages inherit starts
including the Bootstrap CSS, and then my other CSS :

public void renderHead(IHeaderResponse response) {
super.renderHead( response );
Bootstrap.renderHeadResponsive( response );

response.render( CssHeaderItem.forReference( BaseCssResourceReference.get() ) );
...
}

However, on some pages the Bootstrap CSS is included first, like on this
page : http://dubai.windcam.com/winds/gallery
Whilst on others, the mainCSSBundle is included first, like here :
http://dubai.windcam.com/winds/windDailyChart 
or here : http://dubai.windcam.com/winds/
And this breaks the CSS that overloads Bootstrap defaults.

What could be the cause of this ?

I thought that calling calling Bootstrap.renderHeadResponsive( response
) first would ensure this order.
Is there an other way to fix this order ?

Thank you,

Sylvain.


Re: CSS bundles order does not seem stable when using an application

2013-03-17 Thread Sylvain Vieujot
Unfortunately, this does not solve the issue.
It seems that if the page has a wicket:head tag, the order is
disturbed.
This was not the case when my application was not using
getResourceBundles().addCssBundle in the Application.init.

On Sun, 2013-03-17 at 16:26 +0100, Michael Haitz wrote:

 you can add a dependency to the bootstrap resource reference in your own 
 BaseCssResourceReference:
 
 @Override
 public Iterable? extends HeaderItem getDependencies() {
 ListHeaderItem dependencies = new ArrayListHeaderItem();
 
 dependencies.add(JavaScriptHeaderItem.forReference(Bootstrap.plain()));
 
 return dependencies;
 }
 
 here's a short introduction to wicket resource management:
 
 http://wicketinaction.com/2012/07/wicket-6-resource-management/
 
 best,
 Michael
 
 
 Am 17.03.2013 um 07:09 schrieb Sylvain Vieujot sv.mailingli...@gmail.com:
 
  My application is using a resourceBundle to concatenate CSS resources
  via : getResourceBundles().addCssBundle( ... ).
  
  My base wicket page, from which all others pages inherit starts
  including the Bootstrap CSS, and then my other CSS :
  
  public void renderHead(IHeaderResponse response) {
 super.renderHead( response );
 Bootstrap.renderHeadResponsive( response );
  
  response.render( CssHeaderItem.forReference( BaseCssResourceReference.get() 
  ) );
 ...
  }
  
  However, on some pages the Bootstrap CSS is included first, like on this
  page : http://dubai.windcam.com/winds/gallery
  Whilst on others, the mainCSSBundle is included first, like here :
  http://dubai.windcam.com/winds/windDailyChart 
  or here : http://dubai.windcam.com/winds/
  And this breaks the CSS that overloads Bootstrap defaults.
  
  What could be the cause of this ?
  
  I thought that calling calling Bootstrap.renderHeadResponsive( response
  ) first would ensure this order.
  Is there an other way to fix this order ?
  
  Thank you,
  
  Sylvain.
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


Re: CSS bundles order does not seem stable when using an application

2013-03-17 Thread Sylvain Vieujot
Add the bootstrap css resource reference to the bundle would solve the
problem if it were possible.
Indeed the bootstrap css include references to images whose path is
relative to the bootstrap classpath. So adding bootstrap css to a bundle
whose path is not the same as bootstrap will break the bootstrap images.

On Sun, 2013-03-17 at 22:45 +0100, Michael Haitz wrote:

 does adding the bootstrap css resource reference to the bundle solve your 
 problem? 
 
 sorry, i don't have access to the code at the moment.
 
 Am 17.03.2013 um 21:46 schrieb Sylvain Vieujot sv.mailingli...@gmail.com:
 
  Unfortunately, this does not solve the issue.
  It seems that if the page has a wicket:head tag, the order is
  disturbed.
  This was not the case when my application was not using
  getResourceBundles().addCssBundle in the Application.init.
  
  On Sun, 2013-03-17 at 16:26 +0100, Michael Haitz wrote:
  
  you can add a dependency to the bootstrap resource reference in your own 
  BaseCssResourceReference:
  
 @Override
 public Iterable? extends HeaderItem getDependencies() {
 ListHeaderItem dependencies = new ArrayListHeaderItem();
 
  dependencies.add(JavaScriptHeaderItem.forReference(Bootstrap.plain()));
  
 return dependencies;
 }
  
  here's a short introduction to wicket resource management:
  
  http://wicketinaction.com/2012/07/wicket-6-resource-management/
  
  best,
  Michael
  
  
  Am 17.03.2013 um 07:09 schrieb Sylvain Vieujot sv.mailingli...@gmail.com:
  
  My application is using a resourceBundle to concatenate CSS resources
  via : getResourceBundles().addCssBundle( ... ).
  
  My base wicket page, from which all others pages inherit starts
  including the Bootstrap CSS, and then my other CSS :
  
  public void renderHead(IHeaderResponse response) {
super.renderHead( response );
Bootstrap.renderHeadResponsive( response );
  
  response.render( CssHeaderItem.forReference( 
  BaseCssResourceReference.get() ) );
...
  }
  
  However, on some pages the Bootstrap CSS is included first, like on this
  page : http://dubai.windcam.com/winds/gallery
  Whilst on others, the mainCSSBundle is included first, like here :
  http://dubai.windcam.com/winds/windDailyChart 
  or here : http://dubai.windcam.com/winds/
  And this breaks the CSS that overloads Bootstrap defaults.
  
  What could be the cause of this ?
  
  I thought that calling calling Bootstrap.renderHeadResponsive( response
  ) first would ensure this order.
  Is there an other way to fix this order ?
  
  Thank you,
  
  Sylvain.
  
  
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
  
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


Wicket job offer in Dubai

2013-03-17 Thread Sylvain Vieujot
We have a job opening for a good wicket developer.

Emirates REIT ( http://www.reit.ae ) needs to recuite a good developer
that is both good at programming and at suggesting ways to model and
improve our businesses and processes via the IT system.

The job will be based in Dubai, at the Dubai Financial Centre, and
includes expanding our intranet which is quite extensive and key to the
business, and working on a few other smaller projects.

The key skills are :
Wicket, Hibernate, Javascript, Maven and linux administration.

If interested, please contact me at : sylvain at companydomain.

Thank you.

Sylvain Vieujot.


Re: [Wicketstuff] Google Maps 3 component

2012-09-21 Thread Sylvain Vieujot
Hello Joachim,

I am trying to replace Gmap2 with Gmap3 in our webapp, I could not find
a method similar to GMap2's method GInfoWindow.open(GMarker,
Component).\
In GMap3 it seems a GInfoWindow can only have it's content set to a
String.
Is there any plan to implement this, or is there another way of using a
GInfoWindow with a wicket component as content ?

Thank you,

Sylvain.

P.S. I also found that the GMap3's fitMarkers works only for works in
AjaxRequests ( See issue https://github.com/wicketstuff/core/issues/155
)

On Thu, 2012-08-09 at 21:45 +0200, Joachim Rohde wrote:

 Hello,
 
 maybe someone might be interested that I have uploaded a component for 
 Google Maps 3 today which can be found at GitHub under 
 https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/gmap3-parent/gmap3
  
 (I'm not sure when the snapshots are build so it might be necessary to 
 build the project from source still)
 
 A (still) very brief overview can be found in the Wiki: 
 https://github.com/wicketstuff/core/wiki/Gmap3
 
 And the examples are under 
 https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/gmap3-parent/gmap3-examples
 
 So, if anyone is in the need of such a component or just want to play a 
 bit with it, I would appreciate to hear any feedback.
 
 Joachim Rohde
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


Re: Wicket 6 version of GMap2 ?

2012-07-22 Thread Sylvain Vieujot
Ok.
Thank you.

On Sun, 2012-07-22 at 15:50 +0300, Martin Grigorov wrote:

 Hi,
 
 You'll have to build and install it locally until WicketStuff 6.0.0 is 
 released.
 
 On Sun, Jul 22, 2012 at 1:17 AM, Sylvain Vieujot
 sylvain.vieu...@gmail.com wrote:
  Hello,
 
  I upgraded to Wicket 6.0.0-beta 3 and as my webapp uses Wicketstuff's GMAP2,
  I get a java.lang.NoClassDefFoundError:
  org/apache/wicket/markup/html/IHeaderResponse.
 
  I saw here (
  https://github.com/wicketstuff/core/commit/41cc282c3b2d99ea1ba29327439bfe0901001b04
  ) that some work has been done to port GMAP2 to wicket 6.
 
  What dependency  repository should I use in maven to take advantage to this
  ?
 
  Thank you,
 
  Sylvain.
 
 
 


signature.asc
Description: This is a digitally signed message part


Wicket 6 version of GMap2 ?

2012-07-21 Thread Sylvain Vieujot
Hello,

I upgraded to Wicket 6.0.0-beta 3 and as my webapp uses Wicketstuff's
GMAP2, I get a java.lang.NoClassDefFoundError:
org/apache/wicket/markup/html/IHeaderResponse.

I saw here
( 
https://github.com/wicketstuff/core/commit/41cc282c3b2d99ea1ba29327439bfe0901001b04
 ) that some work has been done to port GMAP2 to wicket 6.

What dependency  repository should I use in maven to take advantage to
this ?

Thank you,

Sylvain.


signature.asc
Description: This is a digitally signed message part


Re: Unnecessary 302 redirects in Wicket 1.5

2012-06-25 Thread sylvain
Hi, 
In order to avoid redirect, we add this code in our application class :


setPageRendererProvider(new IPageRendererProvider() {   
@Override
public PageRenderer get(final RenderPageRequestHandler 
context) {
return new WebPageRenderer(context){
@Override
protected RedirectPolicy 
getRedirectPolicy() {
RedirectPolicy result;
if (!((WebRequest) 
RequestCycle.get().getRequest()).isAjax()) {
result = 
RedirectPolicy.NEVER_REDIRECT;
} else {
result = 
super.getRedirectPolicy();
}
return result;
}
};  
}
})

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4650219.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Exception when Session expired

2012-06-13 Thread sylvain
Hi Martin,

Yes it's more correct to put this code page = getExpirationPage(). 

But my problem, when my session expire, I never pass in the onException.

Have you an idea why?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Exception-when-Session-expired-tp4649854p4649913.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Exception when Session expired

2012-06-12 Thread sylvain
Hi,

I miragte in wicket 1.5 and I change the run timeException by this code

getRequestCycleListeners().add(new CommonRequestCycleListener() 
{
@Override
public void 
onExceptionRequestHandlerResolved(RequestCycle cycle,
IRequestHandler handler, Exception exception) {
// TODO Auto-generated method stub
super.onExceptionRequestHandlerResolved(cycle, 
handler, exception);
}

@Override
public IRequestHandler onException(RequestCycle cycle, 
Exception e) {
Page page = new ErrorPage(e);
try {
.

if (e instanceof PageExpiredException) {
Page expirationPage = 
getExpirationPage();
}
} catch 
(QuestionnaireOrFormulaireNotFoundException t) {
page = new 
QuestionnaireOrFormulaireNotFoundPage();
} catch (Throwable t) {
page = new ErrorFormulairePage(t, null);
}
return new RenderPageRequestHandler(new 
PageProvider(page));
}
});
}

it's ok for a lot of error except for the expiration session. 

In wicket 1.4, when my session expired, i had a PageExpiredException but in
wicket 1.5, don't it. 

Have you an idea why? 
How i can catch the exception of the expiration session?

Thanks in advance

Sylvain

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Exception-when-Session-expired-tp4649854.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
Hello,

I have a stateless page, and I would like to periodically refresh a
section of this page.
If I do :

add( new MyPanel( header )
.setOutputMarkupId( true )
.add( new AjaxSelfUpdatingTimerBehavior( Duration.minutes( 2 ) )
  );

The page becomes stateless.

If in MyPanel, I have :
class MyPanel{
 ...
 @Override
 public boolean getStatelessHint(@SuppressWarnings( unused )
Component component) {
  return true;
 }
 ...
}

The update does not work as the expected component's HTML id does not
remain constant :

Wicket.Ajax: Wicket.Ajax.Call.processComponent: Component with id
[[header2]] was not found while trying to perform markup update. Make
sure you called component.setOutputMarkupId(true) on the component whose
markup you are trying to update. console.error('Wicket.Ajax: ' + msg); 
I also tried to use .setVersioned( false ) on both the component and the
page, but without success.
Is there a way to do this ?

Thank you,

Sylvain.


signature.asc
Description: This is a digitally signed message part


Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
Hello,

I have a stateless page, and I would like to periodically refresh a
section of this page.
If I do :

add( new MyPanel( header )
.setOutputMarkupId( true )
.add( new AjaxSelfUpdatingTimerBehavior( Duration.minutes( 2 ) )
  );

The page becomes stateless.

If in MyPanel, I have :
class MyPanel{
 ...
 @Override
 public boolean getStatelessHint(@SuppressWarnings( unused )
Component component) {
  return true;
 }
 ...
}

The update does not work as the expected component's HTML id does not
remain constant :

Wicket.Ajax: Wicket.Ajax.Call.processComponent: Component with id
[[header2]] was not found while trying to perform markup update. Make
sure you called component.setOutputMarkupId(true) on the component whose
markup you are trying to update.
console.error('Wicket.Ajax: ' + msg);

I also tried to use .setVersioned( false ) on both the component and the
page, but without success.
Is there a way to do this ?

Thank you,

Sylvain.


signature.asc
Description: This is a digitally signed message part


Re: Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
The component is indeed stateless, but adding the
AjaxSelfUpdatingTimerBehavior prevents it to staying stateless and
generates an exception like :

Last cause: '[Header [Component id = header]]' claims to be stateless
but isn't. Possible reasons: no stateless hint, statefull behaviors

WicketMessage: Error attaching this container for rendering: [Page class = 
com.windsOfDubai.web.HomePage, id = 2, render count = 1]


I am trying to add the self updating behaviour whilst keeping the page
stateless.


On Wed, 2011-09-07 at 15:09 +0300, Martin Grigorov wrote:

 Hi,
 
 A Component (inc. Page) is stateless by nature.
 
 On Wed, Sep 7, 2011 at 11:51 AM, Sylvain Vieujot
 sylvain.vieu...@gmail.com wrote:
  Hello,
 
  I have a stateless page, and I would like to periodically refresh a section
  of this page.
  If I do :
 
  add( new MyPanel( header )
  .setOutputMarkupId( true )
  .add( new AjaxSelfUpdatingTimerBehavior( Duration.minutes( 2 ) )
);
 
  The page becomes stateless.
 Adding Ajax**Behavior to it makes it stateful because this behavior
 needs to do the callback (onTimer() in your case)
 
  If in MyPanel, I have :
  class MyPanel{
   ...
   @Override
   public boolean getStatelessHint(@SuppressWarnings( unused ) Component
  component) {
return true;
   }
 This makes no difference, since this is the default.
 See org.apache.wicket.Component.getStatelessHint()
 
 But the actual method that decides whether a component is stateless
 is: org.apache.wicket.Component.isStateless()
   ...
  }
 
  The update does not work as the expected component's HTML id does not remain
  constant :
 
  Wicket.Ajax: Wicket.Ajax.Call.processComponent: Component with id
  [[header2]] was not found while trying to perform markup update. Make sure
  you called component.setOutputMarkupId(true) on the component whose markup
  you are trying to update. console.error('Wicket.Ajax: ' + msg);
  I also tried to use .setVersioned( false ) on both the component and the
  page, but without success.
  Is there a way to do this ?
 
  Thank you,
 
  Sylvain.
 
 
 


signature.asc
Description: This is a digitally signed message part


Re: Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
I will look at this.

Thank you.

On Wed, 2011-09-07 at 08:34 -0700, Igor Vaynberg wrote:

 use something like this [1] as a base and build your own timer behavior
 
 [1] 
 https://github.com/jolira/wicket-stateless/blob/master/stateless/src/main/java/com/google/code/joliratools/StatelessAjaxEventBehavior.java
 
 -igor
 
 
 On Wed, Sep 7, 2011 at 3:36 AM, Sylvain Vieujot svieu...@apache.org wrote:
  Hello,
 
  I have a stateless page, and I would like to periodically refresh a section
  of this page.
  If I do :
 
  add( new MyPanel( header )
  .setOutputMarkupId( true )
  .add( new AjaxSelfUpdatingTimerBehavior( Duration.minutes( 2 ) )
);
 
  The page becomes stateless.
 
  If in MyPanel, I have :
  class MyPanel{
   ...
   @Override
   public boolean getStatelessHint(@SuppressWarnings( unused ) Component
  component) {
return true;
   }
   ...
  }
 
  The update does not work as the expected component's HTML id does not remain
  constant :
 
  Wicket.Ajax: Wicket.Ajax.Call.processComponent: Component with id
  [[header2]] was not found while trying to perform markup update. Make sure
  you called component.setOutputMarkupId(true) on the component whose markup
  you are trying to update. console.error('Wicket.Ajax: ' + msg);
  I also tried to use .setVersioned( false ) on both the component and the
  page, but without success.
  Is there a way to do this ?
 
  Thank you,
 
  Sylvain.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


signature.asc
Description: This is a digitally signed message part


Re: Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
I looked at this code, but it does not really help as it has to bind to
an event, whilst I am trying to do an auto update component.

I have 2 questions :

1) Why does the AbstractAjaxBehavior sets the getStatelessHint to
false ?
It seems to me that this non stateless hint could be set much lower in
the classe hierarchy, but I must be missing something.

2) The main problem I have is in the component's id generation.
In Component.getMarkupId, line 1505, we have :
final int generatedMarkupId = storedMarkupId instanceof Integer ?
(Integer)storedMarkupId
: getSession().nextSequenceValue();
So on every request, the id changes because of the
getSession().nextSequenceValue().
If in the Behaviour's onBind method, the component's id is fixed, then I
have no problem ... except this is not very clean programming!

public class StatelessAjaxTimerBehavior extends
AjaxSelfUpdatingTimerBehavior {

public StatelessAjaxTimerBehavior(Duration updateInterval) {
super( updateInterval );
}

@Override
public boolean getStatelessHint(@SuppressWarnings( unused ) Component
component) {
return true;
}

@Override
protected void onBind() {
getComponent().setMarkupId( myForcedID ); // FIXME: This 
works, but
is not very clean ... to say the least
super.onBind();
}
}

Is there a recommended way to fix this ?

Thank you,

Sylvain.

On Wed, 2011-09-07 at 08:34 -0700, Igor Vaynberg wrote:

 use something like this [1] as a base and build your own timer behavior
 
 [1] 
 https://github.com/jolira/wicket-stateless/blob/master/stateless/src/main/java/com/google/code/joliratools/StatelessAjaxEventBehavior.java
 
 -igor
 
 
 On Wed, Sep 7, 2011 at 3:36 AM, Sylvain Vieujot svieu...@apache.org wrote:
  Hello,
 
  I have a stateless page, and I would like to periodically refresh a section
  of this page.
  If I do :
 
  add( new MyPanel( header )
  .setOutputMarkupId( true )
  .add( new AjaxSelfUpdatingTimerBehavior( Duration.minutes( 2 ) )
);
 
  The page becomes stateless.
 
  If in MyPanel, I have :
  class MyPanel{
   ...
   @Override
   public boolean getStatelessHint(@SuppressWarnings( unused ) Component
  component) {
return true;
   }
   ...
  }
 
  The update does not work as the expected component's HTML id does not remain
  constant :
 
  Wicket.Ajax: Wicket.Ajax.Call.processComponent: Component with id
  [[header2]] was not found while trying to perform markup update. Make sure
  you called component.setOutputMarkupId(true) on the component whose markup
  you are trying to update. console.error('Wicket.Ajax: ' + msg);
  I also tried to use .setVersioned( false ) on both the component and the
  page, but without success.
  Is there a way to do this ?
 
  Thank you,
 
  Sylvain.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


signature.asc
Description: This is a digitally signed message part


Re: Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
On Wed, 2011-09-07 at 10:19 -0700, Igor Vaynberg wrote:

 On Wed, Sep 7, 2011 at 10:11 AM, Sylvain Vieujot svieu...@apache.org wrote:
  I looked at this code, but it does not really help as it has to bind to an
  event, whilst I am trying to do an auto update component.
 
  I have 2 questions :
 
  1) Why does the AbstractAjaxBehavior sets the getStatelessHint to false ?
  It seems to me that this non stateless hint could be set much lower in the
  classe hierarchy, but I must be missing something.
 
 because the behavior itself is stateful. it needs to generate a
 callback url to a component, which means it needs a page id - which
 means the page has to exist already - which means it cannot be
 stateless. it works much the same way as a Link component.



But if the page is stateless you should not need the page id, just the
page class to create a new instance isn't it ? (that is if the page's
components ids are stable - see 2 below)


  2) The main problem I have is in the component's id generation.
  In Component.getMarkupId, line 1505, we have :
  final int generatedMarkupId = storedMarkupId instanceof Integer ?
  (Integer)storedMarkupId
  : getSession().nextSequenceValue();
  So on every request, the id changes because of the
  getSession().nextSequenceValue().
  If in the Behaviour's onBind method, the component's id is fixed, then I
  have no problem ... except this is not very clean programming!
 
 if you fix the id yourself you have no way to guarantee it is unique.
 eg if this is a panel you can have two instances of the panel in the
 page, etc. the id itself should not matter much as long as you repaint
 the component so its markup id changes to the new value.

I agree that fixing the id is not a great idea ;-)
But if the id generation could be stable for stateless pages, it would
be quite helpful.
My behaviour needs to repaint a component on a stateless page (which in
the concept is like a stateless version of the clock example
http://www.wicket-library.com/wicket-examples/ajax/clock ).

In the Component id generation, couldn't we replace
getSession().nextSequenceValue() by a new
RequestCycle.get().nextSequenceValue() ( like the Page.getAutoIndex(),
but we can not use the Page.getAutoIndex here as the page is not yet
accessible) ?
The ids would then be fixed for 2 instances of the same stateless page ?
The ids would be much more stable and we could then have stable callback
urls, i.e. stateless behaviours.

Would this work ?

 
 -igor
 
 
 
  public class StatelessAjaxTimerBehavior extends
  AjaxSelfUpdatingTimerBehavior {
 
  public StatelessAjaxTimerBehavior(Duration updateInterval) {
  super( updateInterval );
  }
 
  @Override
  public boolean getStatelessHint(@SuppressWarnings( unused ) Component
  component) {
  return true;
  }
 
  @Override
  protected void onBind() {
  getComponent().setMarkupId( myForcedID ); // FIXME: This works, but is not
  very clean ... to say the least
  super.onBind();
  }
  }
 
  Is there a recommended way to fix this ?
 
  Thank you,
 
  Sylvain.
 
  On Wed, 2011-09-07 at 08:34 -0700, Igor Vaynberg wrote:
 
  use something like this [1] as a base and build your own timer behavior
 
  [1]
  https://github.com/jolira/wicket-stateless/blob/master/stateless/src/main/java/com/google/code/joliratools/StatelessAjaxEventBehavior.java
 
  -igor
 
 
  On Wed, Sep 7, 2011 at 3:36 AM, Sylvain Vieujot svieu...@apache.org wrote:
  Hello,
 
  I have a stateless page, and I would like to periodically refresh a
  section
  of this page.
  If I do :
 
  add( new MyPanel( header )
  .setOutputMarkupId( true )
  .add( new AjaxSelfUpdatingTimerBehavior( Duration.minutes( 2 ) )
);
 
  The page becomes stateless.
 
  If in MyPanel, I have :
  class MyPanel{
   ...
   @Override
   public boolean getStatelessHint(@SuppressWarnings( unused )
  Component
  component) {
return true;
   }
   ...
  }
 
  The update does not work as the expected component's HTML id does not
  remain
  constant :
 
  Wicket.Ajax: Wicket.Ajax.Call.processComponent: Component with id
  [[header2]] was not found while trying to perform markup update. Make sure
  you called component.setOutputMarkupId(
  true) on the component whose markup
  you are trying to update. console.error('Wicket.Ajax: ' + msg);
  I also tried to use .setVersioned( false ) on both the component and the
  page, but without success.
  Is there a way to do this ?
 
  Thank you,
 
  Sylvain.
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
attachment: face-wink.png

signature.asc
Description: This is a digitally signed message part


Re: Stateless page with an auto update section

2011-09-07 Thread Sylvain Vieujot
Using the session does not work, but using the RequestCycle works fine.

Below is how I solved the problem, and it seems to work quite well for
stateless pages.

Thank you for your help.

public class StatelessAjaxSelfUpdatingTimerBehavior extends
AjaxSelfUpdatingTimerBehavior {

private final static MetaDataKeyInteger requestIdsSequenceMetaDataKey
= new MetaDataKeyInteger() {
private static final long serialVersionUID = 1L;
};

static final String GENERATED_IDS_PREFIX = SASUTB;

public StatelessAjaxSelfUpdatingTimerBehavior(Duration updateInterval)
{
super( updateInterval );
}

@Override
public boolean getStatelessHint(@SuppressWarnings( unused ) Component
component) {
return true;
}

private static int getRequestNextSequenceValue() {
Integer currentSequence =
RequestCycle.get().getMetaData( requestIdsSequenceMetaDataKey );
if( currentSequence == null )
currentSequence = 0;
else
currentSequence++;

RequestCycle.get().setMetaData( requestIdsSequenceMetaDataKey,
currentSequence );

return currentSequence;
}

@Override
protected void onBind() {
Object storedMarkupId = getComponent().getMarkupIdImpl();
if( storedMarkupId == null || storedMarkupId instanceof Integer 
){
String markupIdPrefix = id;
if( 
!getComponent().getApplication().usesDeploymentConfig() ){
// in non-deployment mode we make the markup id 
include component id
// so it is easier to debug
markupIdPrefix = getComponent().getId();
}

String markupIdPostfix = GENERATED_IDS_PREFIX +
Integer.toHexString( getRequestNextSequenceValue() ).toLowerCase();

String markupId = markupIdPrefix + markupIdPostfix;

getComponent().setMarkupId( markupId );
}

super.onBind();
}
}

On Wed, 2011-09-07 at 21:42 +0300, Martin Grigorov wrote:

 Session#nextSequenceValue() is public and non-final.
 
 You can override it in YourWebSession to do whatever fits for your
 needs.
 
 
 On Wed, Sep 7, 2011 at 9:35 PM, Sylvain Vieujot svieu...@apache.org
 wrote:
 
 On Wed, 2011-09-07 at 10:19 -0700, Igor Vaynberg wrote: 
 
  On Wed, Sep 7, 2011 at 10:11 AM, Sylvain Vieujot 
 svieu...@apache.org wrote:
   I looked at this code, but it does not really help as it has to 
 bind to an
   event, whilst I am trying to do an auto update component.
  
   I have 2 questions :
  
   1) Why does the AbstractAjaxBehavior sets the getStatelessHint to 
 false ?
   It seems to me that this non stateless hint could be set much 
 lower in the
   classe hierarchy, but I must be missing something.
  
  because the behavior itself is stateful. it needs to generate a
  callback url to a component, which means it needs a page id - which
  means the page has to exist already - which means it cannot be
  stateless. it works much the same way as a Link component.
 
 But if the page is stateless you should not need the page id,
 just the page class to create a new instance isn't it ? (that
 is if the page's components ids are stable - see 2 below)
 
 
 
 
   2) The main problem I have is in the component's id generation.
   In Component.getMarkupId, line 1505, we have :
   final int generatedMarkupId = storedMarkupId instanceof 
 Integer ?
   (Integer)storedMarkupId
   : getSession().nextSequenceValue();
   So on every request, the id changes because of the
   getSession().nextSequenceValue().
   If in the Behaviour's onBind method, the component's id is fixed, 
 then I
   have no problem ... except this is not very clean programming!
  
  if you fix the id yourself you have no way to guarantee it is 
 unique.
  eg if this is a panel you can have two instances of the panel in the
  page, etc. the id itself should not matter much as long as you 
 repaint
  the component so its markup id changes to the new value.
 
 I agree that fixing the id is not a great idea ;-)
 But if the id generation could be stable for stateless pages,
 it would be quite helpful.
 My behaviour needs to repaint a component on a stateless page
 (which in the concept is like a stateless version of the clock
 example
 http://www.wicket-library.com/wicket-examples/ajax/clock