[ANNOUNCE] Apache Wicket 1.5.10 is released

2013-02-26 Thread Martin Grigorov
This is the tenth maintenance release of the Wicket 1.5.x series. This
release brings over 28 bug fixes and improvements.

Git tag:
release/wicket-1.5.10

Changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12310561version=12323510

Maven:
dependency
 groupIdorg.apache.wicket/groupId
 artifactIdwicket-core/artifactId
 version1.5.10/version
/dependency


Download the full distribution (including source):
http://www.apache.org/dyn/closer.cgi/wicket/1.5.10

The Wicket team


Re: page mounting

2013-02-26 Thread Dr. Britta Landgraf
Hi,

in public IRequestHandler mapRequest(final Request request)
the mappers will be sort by:
Collections.sort(list);

So there is no chance to influence the order of the mappers :(

regards britta

Am 25.02.2013 11:18, schrieb Martin Grigorov:
 Hi,

 I've just tried it in a quickstart and my conclusion seems to be valid.
 I am able to reproduce the problem with the initial order and to workaround
 it with the reverse order.

 To debug what happens in your case you can put a breakpoint
 in org.apache.wicket.request.mapper.CompoundRequestMapper#mapRequest().
 Check what is the order of 'list' after the sorting.


 On Mon, Feb 25, 2013 at 12:00 PM, Dr. Britta Landgraf 
 b.landg...@fz-juelich.de wrote:





Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt



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



Re: page mounting

2013-02-26 Thread Martin Grigorov
Hi,

This #sort() sorts by the compatibility score the mapper returns for this
Request.
If two or more mappers return the same score then the order in the list
depends on the order of the mounting in Application#init(), i.e. the order
of insertion in the non-sorted list.


On Tue, Feb 26, 2013 at 11:16 AM, Dr. Britta Landgraf 
b.landg...@fz-juelich.de wrote:

 Hi,

 in public IRequestHandler mapRequest(final Request request)
 the mappers will be sort by:
 Collections.sort(list);

 So there is no chance to influence the order of the mappers :(

 regards britta

 Am 25.02.2013 11:18, schrieb Martin Grigorov:
  Hi,
 
  I've just tried it in a quickstart and my conclusion seems to be valid.
  I am able to reproduce the problem with the initial order and to
 workaround
  it with the reverse order.
 
  To debug what happens in your case you can put a breakpoint
  in org.apache.wicket.request.mapper.CompoundRequestMapper#mapRequest().
  Check what is the order of 'list' after the sorting.
 
 
  On Mon, Feb 25, 2013 at 12:00 PM, Dr. Britta Landgraf 
  b.landg...@fz-juelich.de wrote:




 

 
 Forschungszentrum Juelich GmbH
 52425 Juelich
 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
 Prof. Dr. Sebastian M. Schmidt

 

 

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




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


wicket6-ajax-anchorbrowserhistory

2013-02-26 Thread Oscar Besga Arcauz
 Hi wickers !

First, I'd like to thank all the people that have helped me from this forum: 


Second, I've created a github repo to place a pair of classes that I'm using in 
my projects.

    https://github.com/obaisdefe/wicket6-ajax-anchorbrowserhistory

This code is based on the work of vmontane, at 
https://github.com/vmontane/wicket-ajax-bookmarks
( Also, special thanks to vmontane )

There are two classes:
- A link that changes the hash of the url, the AnchorAjaxLink (really it has no 
ajax action)
- A behaviour to capture, via ajax, the changes made to the hash of the url, 
HistoryAjaxBehaviour

They are based on jQuery and they are working in my code, so feel free to use 
them


The examples can be found in this repo

    https://github.com/obaisdefe/wicket6-ajax-anchorbrowserhistory-example



Any suggestion or enhacement is wellcome !!

Thanks !!!

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



Re: page mounting

2013-02-26 Thread Dr. Britta Landgraf
I solved it now by overriding getCompatibilityScore. Thanks for your hints.

britta

Am 26.02.2013 10:25, schrieb Martin Grigorov:
 Hi,

 This #sort() sorts by the compatibility score the mapper returns for this
 Request.
 If two or more mappers return the same score then the order in the list
 depends on the order of the mounting in Application#init(), i.e. the order
 of insertion in the non-sorted list.


 On Tue, Feb 26, 2013 at 11:16 AM, Dr. Britta Landgraf 
 b.landg...@fz-juelich.de wrote:

 Hi,

 in public IRequestHandler mapRequest(final Request request)
 the mappers will be sort by:
 Collections.sort(list);

 So there is no chance to influence the order of the mappers :(

 regards britta

 Am 25.02.2013 11:18, schrieb Martin Grigorov:
 Hi,

 I've just tried it in a quickstart and my conclusion seems to be valid.
 I am able to reproduce the problem with the initial order and to
 workaround
 it with the reverse order.

 To debug what happens in your case you can put a breakpoint
 in org.apache.wicket.request.mapper.CompoundRequestMapper#mapRequest().
 Check what is the order of 'list' after the sorting.


 On Mon, Feb 25, 2013 at 12:00 PM, Dr. Britta Landgraf 
 b.landg...@fz-juelich.de wrote:



 

 
 Forschungszentrum Juelich GmbH
 52425 Juelich
 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
 Prof. Dr. Sebastian M. Schmidt

 

 

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




-- 
Dr. Britta Landgraf   phone:   +49 2461 61 5647
IEK-4 fax: +49 2461 61 5452
  email:   b.landg...@fz-juelich.de
  WWW: www.fz-juelich.de/iek/iek-4/


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



Re: Integrating Wicket with an Angular app

2013-02-26 Thread sauli.ketola
Ernesto Reinaldo Barreiro-4 wrote
 I want this special page to be be stateless, so I'm planning to serve JSON
  needed via mounted resources.

I've been also playing with a similar idea. Nice to hear that there are
similar attempts going on. In my case I decided to serve the JSON through a
Spring Controller 
http://blog.springsource.org/2009/03/08/rest-in-spring-3-mvc/
http://blog.springsource.org/2009/03/08/rest-in-spring-3-mvc/  . I feel
this makes the service interface more straightforward to implement -
compared to mounted resources.

The motivation for me to do this is that I get to package the angular
application like a standard java web application, and it can then be
deployed to a servlet container like the other applications. If needed, I
also get a session for the application (I can for example check that the
service calls are made in a session + get hold of the user information,
etc). 

Also I have found that none of the javascript frameworks that I have studied
so far have decent support for i18n - with this I could use Wicket for that.
Wicket has also other features that are useful for this like javascript and
css resource serving. (I haven't done this yet but) I think I could add the
required js resources in all of my panels and wicket handles them so that
the javascripts are included in the resulting page only once.

I will try to get a sample application made to demonstrate this.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Integrating-Wicket-with-an-Angular-app-tp4656794p4656820.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: Wicket 6.5.0 upgrade, Extensions Wizard, ApplyState() not called

2013-02-26 Thread Fergal Keating
Hi,

If i put a breakpoint in renderCount (it gets called a lot) But the
resolvePageInstance only gets called once per request,   It seems to have
the same renderCount Value that is on the current page.
E.G. The page is displaying booking?14-1 for all event listeners.


If i change the GroupSize via the Dropdown then the
PageProvider#getPageInstance() is being called with e.g.
pageId=14 renderCount = 1.
The Ajax response contains event Listeners for all the passenger names
textboxes, all the URLs reference booking?14-1.IBehaviorListener as part
of the URL, and when i type in a passenger name it looks like they are
correctly called, but once i click Next the Names are lost.

The Next Button reference a form with the following URL
./booking?14-1.IFormSubmitListener-wizard-form Yet If i Click NEXT then
the page refreshes again and all the Links rerender with booking?14-3

This is consistent with wicket 1.5.5 on the Live site in the same browser,
if i click Next without any passenger names it resets the Booking page, and
moves from e.g 14-1 to 14-3..

I'm not 100% sure where i need to go from here.

On 25 February 2013 13:50, Martin Grigorov mgrigo...@apache.org wrote:

 Hi,

 Such behavior can be experienced when the page is re-rendered in the
 meantime, for example in a new tab/window.
 See Page#renderCount javadoc for explanation.
 To verify that this is or is not the case you can put a breakpoint in
 PageProvider#getPageInstance() method.


 On Mon, Feb 25, 2013 at 3:39 PM, Fergal Keating 
 fergal.keat...@directski.com wrote:

  Hello,
 
  I'm trying to update a wicket 1.5.5 application to 6.5.0. I have overcome
  some issues with Header items, and  setting Attributes to
  AllowDefault(true) for ajax. I have one remaining issue that i cant seem
 to
  figure out.
 
  I have a wizard that allows users to create a booking.
 
  (See currently working version on following Link + Click Book)
 
 http://www.directski.com/ski/france/la_plagne/residence_prestige_sun_valley
 
  When you click Next it calls the applyState() method. However on version
  6.5.0, if you update the Group Size or departure, Clicking Next just
  reloads the page and the applyState() method is not called.
 
  The Group size and departure dropdowns merely use
  AjaxFormComponentUpdatingBehavior to update the object and sends a
  ComponentEvent message to the relevant panels to update themselves.
 
  Any ideas why applyState() might not be being called?
 



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




-- 
Fergal Keating
IT Senior Engineer
---
e. fergal.keat...@directski.com
p. NA
w. www.directski.com


Re: Wicket 6.5.0 upgrade, Extensions Wizard, ApplyState() not called

2013-02-26 Thread Martin Grigorov
Hi,


On Tue, Feb 26, 2013 at 2:10 PM, Fergal Keating 
fergal.keat...@directski.com wrote:

 Hi,

 If i put a breakpoint in renderCount (it gets called a lot) But the
 resolvePageInstance only gets called once per request,   It seems to have
 the same renderCount Value that is on the current page.
 E.G. The page is displaying booking?14-1 for all event listeners.


 If i change the GroupSize via the Dropdown then the
 PageProvider#getPageInstance() is being called with e.g.
 pageId=14 renderCount = 1.
 The Ajax response contains event Listeners for all the passenger names
 textboxes, all the URLs reference booking?14-1.IBehaviorListener as part
 of the URL, and when i type in a passenger name it looks like they are
 correctly called, but once i click Next the Names are lost.

 The Next Button reference a form with the following URL
 ./booking?14-1.IFormSubmitListener-wizard-form Yet If i Click NEXT then
 the page refreshes again and all the Links rerender with booking?14-3

 This is consistent with wicket 1.5.5 on the Live site in the same browser,
 if i click Next without any passenger names it resets the Booking page, and
 moves from e.g 14-1 to 14-3..

 I'm not 100% sure where i need to go from here.


I have no idea too.
If you are able to reproduce the problem in a mini application then attach
it to Jira and we will debug it.



 On 25 February 2013 13:50, Martin Grigorov mgrigo...@apache.org wrote:

  Hi,
 
  Such behavior can be experienced when the page is re-rendered in the
  meantime, for example in a new tab/window.
  See Page#renderCount javadoc for explanation.
  To verify that this is or is not the case you can put a breakpoint in
  PageProvider#getPageInstance() method.
 
 
  On Mon, Feb 25, 2013 at 3:39 PM, Fergal Keating 
  fergal.keat...@directski.com wrote:
 
   Hello,
  
   I'm trying to update a wicket 1.5.5 application to 6.5.0. I have
 overcome
   some issues with Header items, and  setting Attributes to
   AllowDefault(true) for ajax. I have one remaining issue that i cant
 seem
  to
   figure out.
  
   I have a wizard that allows users to create a booking.
  
   (See currently working version on following Link + Click Book)
  
 
 http://www.directski.com/ski/france/la_plagne/residence_prestige_sun_valley
  
   When you click Next it calls the applyState() method. However on
 version
   6.5.0, if you update the Group Size or departure, Clicking Next just
   reloads the page and the applyState() method is not called.
  
   The Group size and departure dropdowns merely use
   AjaxFormComponentUpdatingBehavior to update the object and sends a
   ComponentEvent message to the relevant panels to update themselves.
  
   Any ideas why applyState() might not be being called?
  
 
 
 
  --
  Martin Grigorov
  jWeekend
  Training, Consulting, Development
  http://jWeekend.com http://jweekend.com/
 



 --
 Fergal Keating
 IT Senior Engineer
 ---
 e. fergal.keat...@directski.com
 p. NA
 w. www.directski.com




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


Re: Application name can only be set once

2013-02-26 Thread Sven Meier
How do you create your Application? Do you have a custom 
IWebApplicationFactory?


Sven

On 02/26/2013 03:35 PM, Tom Norton wrote:

We're upgrading from Wicket 1.5.4 to 1.5.9.  The upgrade runs fine on our
local development machines, which run WebLogic 11g.  However, our staging
server, which runs OAS 10g, logs the following error:

13/02/25 16:22:47.269 RIDGIDPortal: Servlet error
java.lang.IllegalStateException: Application name can only be set once.
 at org.apache.wicket.Application.setName(Application.java:849)
 at
org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:340)
 at
org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:271)
 at javax.servlet.GenericServlet.init(GenericServlet.java:256)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.HttpApplication.loadServlet(HttpApplication.java:2361)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.HttpApplication.findServlet(HttpApplication.java:4810)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.HttpApplication.findServlet(HttpApplication.java:4734)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2957)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:736)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
 at
oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
 at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
 at java.lang.Thread.run(Thread.java:595)

This error is logged whenever we try to hit a Wicket page on our staging
server.  Configuring the log4j level to debug shows that no other messages
are logged.

Does anyone have any suggestions?

Thanks,
Tom




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



Re: Application name can only be set once

2013-02-26 Thread Tom Norton
We use the SpringWebApplicationFactory.

Tom


On Tue, Feb 26, 2013 at 10:26 AM, Sven Meier s...@meiers.net wrote:

 How do you create your Application? Do you have a custom
 IWebApplicationFactory?

 Sven


 On 02/26/2013 03:35 PM, Tom Norton wrote:

 We're upgrading from Wicket 1.5.4 to 1.5.9.  The upgrade runs fine on our
 local development machines, which run WebLogic 11g.  However, our staging
 server, which runs OAS 10g, logs the following error:

 13/02/25 16:22:47.269 RIDGIDPortal: Servlet error
 java.lang.**IllegalStateException: Application name can only be set once.
  at org.apache.wicket.Application.**setName(Application.java:849)
  at
 org.apache.wicket.protocol.**http.WicketFilter.init(**
 WicketFilter.java:340)
  at
 org.apache.wicket.protocol.**http.WicketServlet.init(**
 WicketServlet.java:271)
  at javax.servlet.GenericServlet.**init(GenericServlet.java:256)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.HttpApplication.**loadServlet(HttpApplication.**java:2361)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.HttpApplication.**findServlet(HttpApplication.**java:4810)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.HttpApplication.**findServlet(HttpApplication.**java:4734)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.HttpApplication.**getRequestDispatcher(**
 HttpApplication.java:2957)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.**HttpRequestHandler.**doProcessRequest(**
 HttpRequestHandler.java:736)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.**HttpRequestHandler.**processRequest(**
 HttpRequestHandler.java:448)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.**AJPRequestHandler.run(**AJPRequestHandler.java:302)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].server.http.**AJPRequestHandler.run(**AJPRequestHandler.java:190)
  at
 oracle.oc4j.network.**ServerSocketReadHandler$**SafeRunnable.run(**
 ServerSocketReadHandler.java:**260)
  at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0)
 ].util.**ReleasableResourcePooledExecut**or$MyWorker.run(**
 ReleasableResourcePooledExecut**or.java:303)
  at java.lang.Thread.run(Thread.**java:595)

 This error is logged whenever we try to hit a Wicket page on our staging
 server.  Configuring the log4j level to debug shows that no other messages
 are logged.

 Does anyone have any suggestions?

 Thanks,
 Tom



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




Re: URL fragment parsing

2013-02-26 Thread Maxim Solodovnik
AFAIK it is impossible to read URL hash on the server side
Hopefully somebody can write component for that :) I use JS (with the hack
to pass authorization)


On Tue, Feb 26, 2013 at 11:40 PM, Michael Chandler 
michael.chand...@onassignment.com wrote:

 Is it possible to read and parse values in the URL fragment within the
 Wicket API or am I restricted to using JavaScript for that?  For example,
 if I have a URI of http://mydomain.com/my/path#token=key= is
 there a Wicket solution for reading those values or am I stuck with
 JavaScript?

 Mike Chandler




-- 
WBR
Maxim aka solomax


Re: org.apache.wicket.markup.html.link.PopupSettings.java problem (version 6.5.0)

2013-02-26 Thread chrome1235
Thanks for your reply,
I added a quickstart and ticket.
https://issues.apache.org/jira/browse/WICKET-5058



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-markup-html-link-PopupSettings-java-problem-version-6-5-0-tp4656735p4656829.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: URL fragment parsing

2013-02-26 Thread Martin Grigorov
Hi,

The browser doesn't send this information to the server.
You need to read it with JS and send it manually (Ajax).

Earlier today another user shared his project in GitHub about the same.
Read the mail archives.


On Tue, Feb 26, 2013 at 7:02 PM, Maxim Solodovnik solomax...@gmail.comwrote:

 AFAIK it is impossible to read URL hash on the server side
 Hopefully somebody can write component for that :) I use JS (with the hack
 to pass authorization)


 On Tue, Feb 26, 2013 at 11:40 PM, Michael Chandler 
 michael.chand...@onassignment.com wrote:

  Is it possible to read and parse values in the URL fragment within the
  Wicket API or am I restricted to using JavaScript for that?  For example,
  if I have a URI of http://mydomain.com/my/path#token=key= is
  there a Wicket solution for reading those values or am I stuck with
  JavaScript?
 
  Mike Chandler
 
 


 --
 WBR
 Maxim aka solomax




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


Re: OnDomReadyHeaderItems

2013-02-26 Thread Ernesto Reinaldo Barreiro
I don't know if there is a better way... but can always check if you are
NOT in a middle of and AJAX request cycle and if so contribute your script.


On Tue, Feb 26, 2013 at 10:24 PM, Nick Pratt nbpr...@gmail.com wrote:

 With Wicket 6.5.0, is it expected that scripts added in Behavior.renderHead
 ( OnDomReadyHeaderItem.forScript( ... ); ) will be re-rendered and executed
 for partial DOM updates triggered via Ajax?

 If so, is there a way to add a Script to a Behavior such that it only
 renders on a full page re-render?

 N




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


Can a batch job pass back its completion results to Wicket session?

2013-02-26 Thread Nigel Sheridan-Smith
Hi all,

I'm hooking up a data import batch job with Quartz to Wicket and have
struck an issue - how do you notify a Wicket page that the batch job is
complete?

I originally planned to update the Wicket session with the running count of
how many items are processed. However, the Wicket request cycle expires so
it is not possible to update the session after the page is rendered.


To create the job:

JobDataMap dataMap = new JobDataMap();
 dataMap.put(service, getService());
 dataMap.put(deck, deck);
 dataMap.put(importType, importType);
 dataMap.put(fieldMapping, fieldMapping);
 dataMap.put(fileUploaded, fileUploaded);
 dataMap.put(totalRecords, prevImportSummary.totalRecordsInImport);
 dataMap.put(callback, this);
 // Create a new job with a basic trigger
 JobDetail job = newJob(DataImportJob.class
 ).usingJobData(dataMap).build();
 Trigger trigger =
 newTrigger().startNow().withSchedule(simpleSchedule()).build();
 try {
 // Schedule the job for immediate start
 TorScheduler.getScheduler().scheduleJob(job, trigger);
 } catch (SchedulerException se) {
 TorScheduler.getLogger().error(se.getMessage());
 throw new TorException(Cannot start the data import job);
 }

 The data import job uses a callback to the Wicket page:

callback.updateTotal(totalRecords);

callback.updateProgress(/* 0 */ totalRecords, false); // TODO:
 Temporarily skip the progress bar page



// Now add the entries to the repository

ImportSummary importSummary = dataImportProcess.commit(callback);

callback.updateImportSummary(importSummary);


The callback has this implementation (in the page):

 public void updateProgress(int count, boolean error) {

   // Attempt to reuse the same session as before (left open)

  session.setAttribute(importItemsDone, (Integer) count);

  session.setAttribute(importIsInError, (Boolean) error);

 }

  @Override

 public void updateTotal(int total) {


  // Attempt to reuse the same session as before (left open)

  session.setAttribute(importItemsTotal, (Integer) total);

 }


  @Override

 public void updateImportSummary(ImportSummary importSummary) {


  // Attempt to reuse the same session as before (left open)

  session.setAttribute(importSummary, importSummary);

 }


However, I get this exception when attempting to update the Wicket session
with the progress counter:

java.lang.IllegalStateException: Cannot set the attribute: no RequestCycle
available.  If you get this error when using WicketTester.startPage(Page),
make sure to call WicketTester.createRequestCycle() beforehand.
at org.apache.wicket.Session.setAttribute(Session.java:773)
at
com.xxx.tor.webapp.profile.Wiz13ImportResults.updateTotal(Wiz13ImportResults.java:208)
at com.xxx.tor.webapp.batch.DataImportJob.importNow(DataImportJob.java:53)
at com.xxx.tor.webapp.batch.DataImportJob.execute(DataImportJob.java:83)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)


Is this the best approach? Or should I attempt to use methods on the Quartz
scheduler to get the current progress of the batch job from within
AbstractAjaxTimerBehavior.onTimer( )?

I am using the JQWicket (jQuery UI) progress bar... with a 5 second delay
on updates to the page.

Cheers,

Nigel


-- 
e: ni...@joinsomeone.com
m: +61 403 930 963

Get together for fun activities at www.joinsomeone.com

Like us on Facebook www.facebook.com/JoinSomeone
Follow us on Twitter @JoinSomeone


Re: Can a batch job pass back its completion results to Wicket session?

2013-02-26 Thread Paul Bors
I would look at Observable and Observer class in java to achieve signal
sort of behavior.

On Tue, Feb 26, 2013 at 5:47 PM, Nigel Sheridan-Smith wtfi...@gmail.comwrote:

 Hi all,

 I'm hooking up a data import batch job with Quartz to Wicket and have
 struck an issue - how do you notify a Wicket page that the batch job is
 complete?

 I originally planned to update the Wicket session with the running count of
 how many items are processed. However, the Wicket request cycle expires so
 it is not possible to update the session after the page is rendered.


 To create the job:

 JobDataMap dataMap = new JobDataMap();
  dataMap.put(service, getService());
  dataMap.put(deck, deck);
  dataMap.put(importType, importType);
  dataMap.put(fieldMapping, fieldMapping);
  dataMap.put(fileUploaded, fileUploaded);
  dataMap.put(totalRecords, prevImportSummary.totalRecordsInImport);
  dataMap.put(callback, this);
  // Create a new job with a basic trigger
  JobDetail job = newJob(DataImportJob.class
  ).usingJobData(dataMap).build();
  Trigger trigger =
  newTrigger().startNow().withSchedule(simpleSchedule()).build();
  try {
  // Schedule the job for immediate start
  TorScheduler.getScheduler().scheduleJob(job, trigger);
  } catch (SchedulerException se) {
  TorScheduler.getLogger().error(se.getMessage());
  throw new TorException(Cannot start the data import job);
  }

  The data import job uses a callback to the Wicket page:

 callback.updateTotal(totalRecords);
 
 callback.updateProgress(/* 0 */ totalRecords, false); // TODO:
  Temporarily skip the progress bar page
 

 
 // Now add the entries to the repository
 
 ImportSummary importSummary = dataImportProcess.commit(callback);
 
 callback.updateImportSummary(importSummary);
 

 The callback has this implementation (in the page):

  public void updateProgress(int count, boolean error) {
 
// Attempt to reuse the same session as before (left open)
 
   session.setAttribute(importItemsDone, (Integer) count);
 
   session.setAttribute(importIsInError, (Boolean) error);
 
  }
 
   @Override
 
  public void updateTotal(int total) {
 
 
   // Attempt to reuse the same session as before (left open)
 
   session.setAttribute(importItemsTotal, (Integer) total);
 
  }
 
 
   @Override
 
  public void updateImportSummary(ImportSummary importSummary) {
 
 
   // Attempt to reuse the same session as before (left open)
 
   session.setAttribute(importSummary, importSummary);
 
  }
 

 However, I get this exception when attempting to update the Wicket session
 with the progress counter:

 java.lang.IllegalStateException: Cannot set the attribute: no RequestCycle
 available.  If you get this error when using WicketTester.startPage(Page),
 make sure to call WicketTester.createRequestCycle() beforehand.
 at org.apache.wicket.Session.setAttribute(Session.java:773)
 at

 com.xxx.tor.webapp.profile.Wiz13ImportResults.updateTotal(Wiz13ImportResults.java:208)
 at com.xxx.tor.webapp.batch.DataImportJob.importNow(DataImportJob.java:53)
 at com.xxx.tor.webapp.batch.DataImportJob.execute(DataImportJob.java:83)
 at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
 at

 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)


 Is this the best approach? Or should I attempt to use methods on the Quartz
 scheduler to get the current progress of the batch job from within
 AbstractAjaxTimerBehavior.onTimer( )?

 I am using the JQWicket (jQuery UI) progress bar... with a 5 second delay
 on updates to the page.

 Cheers,

 Nigel


 --
 e: ni...@joinsomeone.com
 m: +61 403 930 963

 Get together for fun activities at www.joinsomeone.com

 Like us on Facebook www.facebook.com/JoinSomeone
 Follow us on Twitter @JoinSomeone



How to automatically add a parameter to every request

2013-02-26 Thread Florian Braun
Hello, 

I am currently in the process of migrating an application from Wicket 1.4 to 
Wicket 6.

In my application I have a parameter that needs to be part of every request 
(kind of like pageMaps used to be in 1.4).
This means I have to check each request to see if the parameter is there and if 
not create a new one and add it.

In Wicket 1.4 I had logic in the resolve() method of the 
WebRequestCycleProcessor where I basically called setResponsePage() with the 
new parameter and threw a AbstractRestartResponseException().

In Wicket 6 I was able to achieve the same by creating a custom Mapper that 
extends the MountedMapper.
In this Mapper I added logic to the parseRequest method to check if the UrlInfo 
includes the parameter and if not create a new UrlInfo instance based on the 
original one that includes the parameter.

This works but it requires that all pages are mounted with this specific 
Mapper. 

Is there a better way to add this logic so that it automatically applies to 
every request and does not require the developers to use the custom mapper?

Thanks,
Florian

Re: How to automatically add a parameter to every request

2013-02-26 Thread Igor Vaynberg
see IRequestCycleListener#onUrlMapped()

-igor

On Tue, Feb 26, 2013 at 6:35 PM, Florian Braun florianbrau...@gmail.com wrote:
 Hello,

 I am currently in the process of migrating an application from Wicket 1.4 to 
 Wicket 6.

 In my application I have a parameter that needs to be part of every request 
 (kind of like pageMaps used to be in 1.4).
 This means I have to check each request to see if the parameter is there and 
 if not create a new one and add it.

 In Wicket 1.4 I had logic in the resolve() method of the 
 WebRequestCycleProcessor where I basically called setResponsePage() with the 
 new parameter and threw a AbstractRestartResponseException().

 In Wicket 6 I was able to achieve the same by creating a custom Mapper that 
 extends the MountedMapper.
 In this Mapper I added logic to the parseRequest method to check if the 
 UrlInfo includes the parameter and if not create a new UrlInfo instance based 
 on the original one that includes the parameter.

 This works but it requires that all pages are mounted with this specific 
 Mapper.

 Is there a better way to add this logic so that it automatically applies to 
 every request and does not require the developers to use the custom mapper?

 Thanks,
 Florian

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



Re: Handle JSON response

2013-02-26 Thread Paul Bors
There is a wiki page on that:
https://cwiki.apache.org/WICKET/how-to-write-json-response.html

~ Thank you,
   Paul C Bors

On Feb 26, 2013, at 20:33, abarretto abarrett...@gmail.com wrote:

 Hi,
 
 I'm a beginner in Wicket and I need to develop a simple application that
 make an AJAX request to an URL using a link, which must return a JSON
 response. I need to handle the content of this response to show it in a div
 of the page (without reload it, of course).
 
 So, I have the url that returns the JSON response, like this:
 http:localhost/offices. My simple application seems like this:
 
 -- MyAjax.java
 -
 
 public class MyAjax extends WebPage {
 
private static final long serialVersionUID = 1L;

private final class MyLink extends AjaxFallbackLink {
public MyLink(String id) {
super(id);
}

public void onClick(AjaxRequestTarget target){}

public void updateAjaxAttributes(AjaxRequestAttributes attributes) {

super.updateAjaxAttributes(attributes);
attributes.setDataType(json);
attributes.setWicketAjaxResponse(false);

AjaxCallListener listener = new AjaxCallListener() {
private static final long serialVersionUID = 1L;
CharSequence handler =
 $(\#content\).text(data.offices[0].officeCode);

@Override
public CharSequence getSuccessHandler(Component component) {
return handler;
}
  };
 attributes.getAjaxCallListeners().add(listener);
}

protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
String url = /offices;
tag.put(href, url);
}
}

public MyAjax(final PageParameters parameters) {
super(parameters);
MyLink ajaxLink = new MyLink(ajaxLink);
add(ajaxLink);
}
 }
 --
 - MyAjax.html 
 html
 head
 meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1
 titleMyAjax Application/title
 /head
 body
 Get JSON br
 div id = content /
 /body
 /html
 --
 When the MyAjax.html is rendered, I can see that the link GET JSON point
 to URL /offices (that return the JSON response), but, when it is clicked, it
 doesn't go to that URL. Indeed, it makes a request to an URL generated
 automatically by AjaxFallbackLink, something like
 http:/localhost/myajax/?-1.IBehavoirListener.-ajaxLink=some_number
 
 Additionally, an Javascript code is generated after MyAjax.html is rendered
 to indicate the url of the Ajax Request. Something like this:
 
 --- MyAjax.html (rendered) -
 Wicket.Event.add(window, domready, function(event) { 
 Wicket.Ajax.ajax({dt:json*,u:./?0-1.IBehaviorListener.0-ajaxLink*,e:click,c:ajaxLink,wr:false,sh:[function(attrs,
 jqXHR, data, textStatus){var response = ; for(var i = 0; i 
 data.offices.length; i++) {response += data.offices[i].officeCode + ; 
 }$(#content).text(response)}]});;
 ;});
 .
 href=/mgm/JSONOffice*Get JSON br
 
 
 My question is: Can I set this automatically link in a way that it uses my
 JSON URL? If not, there is a way that a can access an URL that returns a
 JSON response and handle the response to show it in the page?
 
 Thanks.
 Anderson
 
 
 
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Handle-JSON-response-tp4656838.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: Handle JSON response

2013-02-26 Thread Paul Bors
If you want to see a simple project using Jackson to render JSON on the page 
take a look at:
http://wicket-continuous-calendar.GoogleCode.com/

Or a bit bigger one:
http://wicked-charts.GoogleCode.com

Or poke around other open source code projects in Wicket that use those 
dependencies in Maven.

~ Thank you,
   Paul C Bors

On Feb 26, 2013, at 23:29, Paul Bors p...@bors.ws wrote:

 There is a wiki page on that:
 https://cwiki.apache.org/WICKET/how-to-write-json-response.html
 
 ~ Thank you,
Paul C Bors
 
 On Feb 26, 2013, at 20:33, abarretto abarrett...@gmail.com wrote:
 
 Hi,
 
 I'm a beginner in Wicket and I need to develop a simple application that
 make an AJAX request to an URL using a link, which must return a JSON
 response. I need to handle the content of this response to show it in a div
 of the page (without reload it, of course).
 
 So, I have the url that returns the JSON response, like this:
 http:localhost/offices. My simple application seems like this:
 
 -- MyAjax.java
 -
 
 public class MyAjax extends WebPage {
 
private static final long serialVersionUID = 1L;

private final class MyLink extends AjaxFallbackLink {
public MyLink(String id) {
super(id);
}

public void onClick(AjaxRequestTarget target){}

public void updateAjaxAttributes(AjaxRequestAttributes attributes) {

super.updateAjaxAttributes(attributes);
attributes.setDataType(json);
attributes.setWicketAjaxResponse(false);

AjaxCallListener listener = new AjaxCallListener() {
private static final long serialVersionUID = 1L;
CharSequence handler =
 $(\#content\).text(data.offices[0].officeCode);

@Override
public CharSequence getSuccessHandler(Component component) {
return handler;
}
  };
 attributes.getAjaxCallListeners().add(listener);
}

protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
String url = /offices;
tag.put(href, url);
}
}

public MyAjax(final PageParameters parameters) {
super(parameters);
MyLink ajaxLink = new MyLink(ajaxLink);
add(ajaxLink);
}
 }
 --
 - MyAjax.html 
 html
 head
 meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1
 titleMyAjax Application/title
 /head
 body
 Get JSON br
 div id = content /
 /body
 /html
 --
 When the MyAjax.html is rendered, I can see that the link GET JSON point
 to URL /offices (that return the JSON response), but, when it is clicked, it
 doesn't go to that URL. Indeed, it makes a request to an URL generated
 automatically by AjaxFallbackLink, something like
 http:/localhost/myajax/?-1.IBehavoirListener.-ajaxLink=some_number
 
 Additionally, an Javascript code is generated after MyAjax.html is rendered
 to indicate the url of the Ajax Request. Something like this:
 
 --- MyAjax.html (rendered) -
 Wicket.Event.add(window, domready, function(event) { 
 Wicket.Ajax.ajax({dt:json*,u:./?0-1.IBehaviorListener.0-ajaxLink*,e:click,c:ajaxLink,wr:false,sh:[function(attrs,
 jqXHR, data, textStatus){var response = ; for(var i = 0; i 
 data.offices.length; i++) {response += data.offices[i].officeCode + ; 
 }$(#content).text(response)}]});;
 ;});
 .
 href=/mgm/JSONOffice*Get JSON br
 
 
 My question is: Can I set this automatically link in a way that it uses my
 JSON URL? If not, there is a way that a can access an URL that returns a
 JSON response and handle the response to show it in the page?
 
 Thanks.
 Anderson
 
 
 
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Handle-JSON-response-tp4656838.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: Can a batch job pass back its completion results to Wicket session?

2013-02-26 Thread Ernesto Reinaldo Barreiro
Hi,

I remember I have done this by creating a class that serves a progress
watching context and sharing an instance of this class between Wicket
Session (or a page or component) and the quartz job. This class acted as
a wire to pass information between the two threads (e.g. progress,
cancel the JOB, etc). I also used an AJAX timer too poll server. I think
there is an example of how to do that at

http://code.google.com/p/antilia/source/browse/#svn%2Ftrunk%2Fcom.antilia.export%2Fsrc%2Fcom%2Fantilia%2Fexport%2Fpdf

Thought code is quite old...


On Tue, Feb 26, 2013 at 11:47 PM, Nigel Sheridan-Smith wtfi...@gmail.comwrote:

 Hi all,

 I'm hooking up a data import batch job with Quartz to Wicket and have
 struck an issue - how do you notify a Wicket page that the batch job is
 complete?

 I originally planned to update the Wicket session with the running count of
 how many items are processed. However, the Wicket request cycle expires so
 it is not possible to update the session after the page is rendered.


 To create the job:

 JobDataMap dataMap = new JobDataMap();
  dataMap.put(service, getService());
  dataMap.put(deck, deck);
  dataMap.put(importType, importType);
  dataMap.put(fieldMapping, fieldMapping);
  dataMap.put(fileUploaded, fileUploaded);
  dataMap.put(totalRecords, prevImportSummary.totalRecordsInImport);
  dataMap.put(callback, this);
  // Create a new job with a basic trigger
  JobDetail job = newJob(DataImportJob.class
  ).usingJobData(dataMap).build();
  Trigger trigger =
  newTrigger().startNow().withSchedule(simpleSchedule()).build();
  try {
  // Schedule the job for immediate start
  TorScheduler.getScheduler().scheduleJob(job, trigger);
  } catch (SchedulerException se) {
  TorScheduler.getLogger().error(se.getMessage());
  throw new TorException(Cannot start the data import job);
  }

  The data import job uses a callback to the Wicket page:

 callback.updateTotal(totalRecords);
 
 callback.updateProgress(/* 0 */ totalRecords, false); // TODO:
  Temporarily skip the progress bar page
 

 
 // Now add the entries to the repository
 
 ImportSummary importSummary = dataImportProcess.commit(callback);
 
 callback.updateImportSummary(importSummary);
 

 The callback has this implementation (in the page):

  public void updateProgress(int count, boolean error) {
 
// Attempt to reuse the same session as before (left open)
 
   session.setAttribute(importItemsDone, (Integer) count);
 
   session.setAttribute(importIsInError, (Boolean) error);
 
  }
 
   @Override
 
  public void updateTotal(int total) {
 
 
   // Attempt to reuse the same session as before (left open)
 
   session.setAttribute(importItemsTotal, (Integer) total);
 
  }
 
 
   @Override
 
  public void updateImportSummary(ImportSummary importSummary) {
 
 
   // Attempt to reuse the same session as before (left open)
 
   session.setAttribute(importSummary, importSummary);
 
  }
 

 However, I get this exception when attempting to update the Wicket session
 with the progress counter:

 java.lang.IllegalStateException: Cannot set the attribute: no RequestCycle
 available.  If you get this error when using WicketTester.startPage(Page),
 make sure to call WicketTester.createRequestCycle() beforehand.
 at org.apache.wicket.Session.setAttribute(Session.java:773)
 at

 com.xxx.tor.webapp.profile.Wiz13ImportResults.updateTotal(Wiz13ImportResults.java:208)
 at com.xxx.tor.webapp.batch.DataImportJob.importNow(DataImportJob.java:53)
 at com.xxx.tor.webapp.batch.DataImportJob.execute(DataImportJob.java:83)
 at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
 at

 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)


 Is this the best approach? Or should I attempt to use methods on the Quartz
 scheduler to get the current progress of the batch job from within
 AbstractAjaxTimerBehavior.onTimer( )?

 I am using the JQWicket (jQuery UI) progress bar... with a 5 second delay
 on updates to the page.

 Cheers,

 Nigel


 --
 e: ni...@joinsomeone.com
 m: +61 403 930 963

 Get together for fun activities at www.joinsomeone.com

 Like us on Facebook www.facebook.com/JoinSomeone
 Follow us on Twitter @JoinSomeone




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


Re: Can a batch job pass back its completion results to Wicket session?

2013-02-26 Thread Nigel Sheridan-Smith
Thanks Paul and Ernesto,

After much stuffing around, I managed to get this to work: modifying the
JobDataMap within the Quartz job. However, you must re-publish the map
after it has been changed, as Quartz serializes it and doesn't update it
until after the job finishes executing. You might also need the
@PersistJobDataAfterExecution and @DisallowConcurrentExecution annotations
on the Quartz job to make it stateful.

The callback:

 if (callback != null) {
   callback.updateProgress(resultSummary.successullyImportedRecords +
 resultSummary.unSuccessullyImportedRecords, false);
  }



The updateProgress( ) callback on the Quartz job:

public void updateProgress(int count, boolean error) {
 try {
 dataMap.put(results_counter, (int) count);
 dataMap.put(results_error, error);

 // Update the job detail and the associated data map (serialized in
 RAM?)
 TorScheduler.getScheduler().addJob(jobDetail, true);

 } catch (SchedulerException e) {
 e.printStackTrace();
 logger.error(Error when updating the job details:  + e.getMessage());
 }
 }


The Progress Bar within the Wicket page:


add(new AbstractAjaxTimerBehavior(Duration.seconds(3)) {
 private static final long serialVersionUID = 1L;
 @Override
 protected void onTimer(AjaxRequestTarget target) {
 TorSession session = TorSession.get();
 progressbar.value(target, counter);
 JobKey jobKey = (JobKey) session.getAttribute(
 importJobKey);
 System.out.println (job key:  + jobKey);

 boolean error = false;
 try {
 Scheduler scheduler = TorScheduler.getScheduler();
 JobDetail jobDetails = scheduler.getJobDetail(jobKey);

 if (jobDetails == null) {
  System.out.println (Job finished?);
 PageParameters pp = new PageParameters().set(p, deck
 .getId().getTudi());
 setResponsePage(Wiz14ImportComplete.class, pp);
 return;
 }

 JobDataMap jobDataMap = jobDetails.getJobDataMap();

 counter = jobDataMap.getIntValue(results_counter);
 error = jobDataMap.getBooleanValue(results_error);

 } catch (SchedulerException e) {
 error(Error with import batch process:  + e.getMessage());
 setUpdateInterval(Duration.NONE);
 target.add(curr);
 return;
 }

 if (error) {
 error(Error occurred during the import batch process);
 setUpdateInterval(Duration.NONE);
 } else {
 // Redirect if we get the max count
 if (counter = maxItems) {
 PageParameters pp = new PageParameters().set(p, deck
 .getId().getTudi());
 setResponsePage(Wiz14ImportComplete.class, pp);
 }
 }

 target.add(curr);
 }
 });


Cheers,

Nigel




On Wed, Feb 27, 2013 at 5:14 PM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 Hi,

 I remember I have done this by creating a class that serves a progress
 watching context and sharing an instance of this class between Wicket
 Session (or a page or component) and the quartz job. This class acted as
 a wire to pass information between the two threads (e.g. progress,
 cancel the JOB, etc). I also used an AJAX timer too poll server. I think
 there is an example of how to do that at


 http://code.google.com/p/antilia/source/browse/#svn%2Ftrunk%2Fcom.antilia.export%2Fsrc%2Fcom%2Fantilia%2Fexport%2Fpdf

 Thought code is quite old...


 On Tue, Feb 26, 2013 at 11:47 PM, Nigel Sheridan-Smith wtfi...@gmail.com
 wrote:

  Hi all,
 
  I'm hooking up a data import batch job with Quartz to Wicket and have
  struck an issue - how do you notify a Wicket page that the batch job is
  complete?
 
  I originally planned to update the Wicket session with the running count
 of
  how many items are processed. However, the Wicket request cycle expires
 so
  it is not possible to update the session after the page is rendered.
 
 
  To create the job:
 
  JobDataMap dataMap = new JobDataMap();
   dataMap.put(service, getService());
   dataMap.put(deck, deck);
   dataMap.put(importType, importType);
   dataMap.put(fieldMapping, fieldMapping);
   dataMap.put(fileUploaded, fileUploaded);
   dataMap.put(totalRecords, prevImportSummary.totalRecordsInImport);
   dataMap.put(callback, this);
   // Create a new job with a basic trigger
   JobDetail job = newJob(DataImportJob.class
   ).usingJobData(dataMap).build();
   Trigger trigger =
   newTrigger().startNow().withSchedule(simpleSchedule()).build();
   try {
   // Schedule the job for immediate start
   TorScheduler.getScheduler().scheduleJob(job, trigger);
   } catch (SchedulerException se) {
   TorScheduler.getLogger().error(se.getMessage());
   throw new TorException(Cannot start the data import job);
   }
 
   The data import job uses a callback to the Wicket page:
 
  callback.updateTotal(totalRecords);
  
  callback.updateProgress(/* 0 */ 

Re: Can a batch job pass back its completion results to Wicket session?

2013-02-26 Thread Ernesto Reinaldo Barreiro
Hi,

On Wed, Feb 27, 2013 at 7:32 AM, Nigel Sheridan-Smith wtfi...@gmail.comwrote:

 Thanks Paul and Ernesto,

 After much stuffing around, I managed to get this to work: modifying the
 JobDataMap within the Quartz job. However, you must re-publish the map
 after it has been changed, as Quartz serializes it and doesn't update it
 until after the job finishes executing. You might also need the
 @PersistJobDataAfterExecution and @DisallowConcurrentExecution annotations
 on the Quartz job to make it stateful.

 I remember using a quartz listener to attach/remove this progress
reporting class to the Job... So that that progress class did not need to
be stored. I don't remember if it was a thread local context like class


 The callback:

  if (callback != null) {
callback.updateProgress(resultSummary.successullyImportedRecords +
  resultSummary.unSuccessullyImportedRecords, false);
   }



 The updateProgress( ) callback on the Quartz job:

 public void updateProgress(int count, boolean error) {
  try {
  dataMap.put(results_counter, (int) count);
  dataMap.put(results_error, error);
 
  // Update the job detail and the associated data map (serialized in
  RAM?)
  TorScheduler.getScheduler().addJob(jobDetail, true);
 
  } catch (SchedulerException e) {
  e.printStackTrace();
  logger.error(Error when updating the job details:  + e.getMessage());
  }
  }


 The Progress Bar within the Wicket page:


 add(new AbstractAjaxTimerBehavior(Duration.seconds(3)) {
  private static final long serialVersionUID = 1L;
  @Override
  protected void onTimer(AjaxRequestTarget target) {
  TorSession session = TorSession.get();
  progressbar.value(target, counter);
  JobKey jobKey = (JobKey) session.getAttribute(
  importJobKey);
  System.out.println (job key:  + jobKey);
 
  boolean error = false;
  try {
  Scheduler scheduler = TorScheduler.getScheduler();
  JobDetail jobDetails = scheduler.getJobDetail(jobKey);
 
  if (jobDetails == null) {
   System.out.println (Job finished?);
  PageParameters pp = new PageParameters().set(p, deck
  .getId().getTudi());
  setResponsePage(Wiz14ImportComplete.class, pp);
  return;
  }
 
  JobDataMap jobDataMap = jobDetails.getJobDataMap();
 
  counter = jobDataMap.getIntValue(results_counter);
  error = jobDataMap.getBooleanValue(results_error);
 
  } catch (SchedulerException e) {
  error(Error with import batch process:  + e.getMessage());
  setUpdateInterval(Duration.NONE);
  target.add(curr);
  return;
  }
 
  if (error) {
  error(Error occurred during the import batch process);
  setUpdateInterval(Duration.NONE);
  } else {
  // Redirect if we get the max count
  if (counter = maxItems) {
  PageParameters pp = new PageParameters().set(p, deck
  .getId().getTudi());
  setResponsePage(Wiz14ImportComplete.class, pp);
  }
  }
 
  target.add(curr);
  }
  });


 Cheers,

 Nigel




 On Wed, Feb 27, 2013 at 5:14 PM, Ernesto Reinaldo Barreiro 
 reier...@gmail.com wrote:

  Hi,
 
  I remember I have done this by creating a class that serves a progress
  watching context and sharing an instance of this class between Wicket
  Session (or a page or component) and the quartz job. This class acted
 as
  a wire to pass information between the two threads (e.g. progress,
  cancel the JOB, etc). I also used an AJAX timer too poll server. I think
  there is an example of how to do that at
 
 
 
 http://code.google.com/p/antilia/source/browse/#svn%2Ftrunk%2Fcom.antilia.export%2Fsrc%2Fcom%2Fantilia%2Fexport%2Fpdf
 
  Thought code is quite old...
 
 
  On Tue, Feb 26, 2013 at 11:47 PM, Nigel Sheridan-Smith 
 wtfi...@gmail.com
  wrote:
 
   Hi all,
  
   I'm hooking up a data import batch job with Quartz to Wicket and have
   struck an issue - how do you notify a Wicket page that the batch job is
   complete?
  
   I originally planned to update the Wicket session with the running
 count
  of
   how many items are processed. However, the Wicket request cycle expires
  so
   it is not possible to update the session after the page is rendered.
  
  
   To create the job:
  
   JobDataMap dataMap = new JobDataMap();
dataMap.put(service, getService());
dataMap.put(deck, deck);
dataMap.put(importType, importType);
dataMap.put(fieldMapping, fieldMapping);
dataMap.put(fileUploaded, fileUploaded);
dataMap.put(totalRecords, prevImportSummary.totalRecordsInImport);
dataMap.put(callback, this);
// Create a new job with a basic trigger
JobDetail job = newJob(DataImportJob.class
).usingJobData(dataMap).build();
Trigger trigger =

Re: Handle JSON response

2013-02-26 Thread Martin Grigorov
Hi,

The demo app for what's new in Wicket 6's JavaScript does exactly this:
http://wicketinaction.com/2012/07/wicket-6-javascript-improvements/


On Wed, Feb 27, 2013 at 6:34 AM, Paul Bors p...@bors.ws wrote:

 If you want to see a simple project using Jackson to render JSON on the
 page take a look at:
 http://wicket-continuous-calendar.GoogleCode.com/

 Or a bit bigger one:
 http://wicked-charts.GoogleCode.com

 Or poke around other open source code projects in Wicket that use those
 dependencies in Maven.

 ~ Thank you,
Paul C Bors

 On Feb 26, 2013, at 23:29, Paul Bors p...@bors.ws wrote:

  There is a wiki page on that:
  https://cwiki.apache.org/WICKET/how-to-write-json-response.html
 
  ~ Thank you,
 Paul C Bors
 
  On Feb 26, 2013, at 20:33, abarretto abarrett...@gmail.com wrote:
 
  Hi,
 
  I'm a beginner in Wicket and I need to develop a simple application that
  make an AJAX request to an URL using a link, which must return a JSON
  response. I need to handle the content of this response to show it in a
 div
  of the page (without reload it, of course).
 
  So, I have the url that returns the JSON response, like this:
  http:localhost/offices. My simple application seems like this:
 
  -- MyAjax.java
  -
 
  public class MyAjax extends WebPage {
 
 private static final long serialVersionUID = 1L;
 
 private final class MyLink extends AjaxFallbackLink {
 public MyLink(String id) {
 super(id);
 }
 
 public void onClick(AjaxRequestTarget target){}
 
 public void updateAjaxAttributes(AjaxRequestAttributes
 attributes) {
 
 super.updateAjaxAttributes(attributes);
 attributes.setDataType(json);
 attributes.setWicketAjaxResponse(false);
 
 AjaxCallListener listener = new AjaxCallListener() {
 private static final long serialVersionUID = 1L;
 CharSequence handler =
  $(\#content\).text(data.offices[0].officeCode);
 
 @Override
 public CharSequence getSuccessHandler(Component
 component) {
 return handler;
 }
   };
  attributes.getAjaxCallListeners().add(listener);
 }
 
 protected void onComponentTag(ComponentTag tag) {
 super.onComponentTag(tag);
 String url = /offices;
 tag.put(href, url);
 }
 }
 
 public MyAjax(final PageParameters parameters) {
 super(parameters);
 MyLink ajaxLink = new MyLink(ajaxLink);
 add(ajaxLink);
 }
  }
  --
  - MyAjax.html 
  html
  head
  meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1
  titleMyAjax Application/title
  /head
  body
  Get JSON br
  div id = content /
  /body
  /html
  --
  When the MyAjax.html is rendered, I can see that the link GET JSON
 point
  to URL /offices (that return the JSON response), but, when it is
 clicked, it
  doesn't go to that URL. Indeed, it makes a request to an URL generated
  automatically by AjaxFallbackLink, something like
  http:/localhost/myajax/?-1.IBehavoirListener.-ajaxLink=some_number
 
  Additionally, an Javascript code is generated after MyAjax.html is
 rendered
  to indicate the url of the Ajax Request. Something like this:
 
  --- MyAjax.html (rendered) -
  Wicket.Event.add(window, domready, function(event) {
 
 Wicket.Ajax.ajax({dt:json*,u:./?0-1.IBehaviorListener.0-ajaxLink*,e:click,c:ajaxLink,wr:false,sh:[function(attrs,
  jqXHR, data, textStatus){var response = ; for(var i = 0; i 
  data.offices.length; i++) {response += data.offices[i].officeCode + ; 
  }$(#content).text(response)}]});;
  ;});
  .
  href=/mgm/JSONOffice*Get JSON br
 
 
  My question is: Can I set this automatically link in a way that it uses
 my
  JSON URL? If not, there is a way that a can access an URL that returns a
  JSON response and handle the response to show it in the page?
 
  Thanks.
  Anderson
 
 
 
  --
  View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Handle-JSON-response-tp4656838.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
 




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


Re: How to automatically add a parameter to every request

2013-02-26 Thread Martin Grigorov
Hi,

You can also use a custom root mapper that does this for all wrapped
mappers.
See how HttpsMapper and CryptoMapper work.


On Wed, Feb 27, 2013 at 4:55 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 see IRequestCycleListener#onUrlMapped()

 -igor

 On Tue, Feb 26, 2013 at 6:35 PM, Florian Braun florianbrau...@gmail.com
 wrote:
  Hello,
 
  I am currently in the process of migrating an application from Wicket
 1.4 to Wicket 6.
 
  In my application I have a parameter that needs to be part of every
 request (kind of like pageMaps used to be in 1.4).
  This means I have to check each request to see if the parameter is there
 and if not create a new one and add it.
 
  In Wicket 1.4 I had logic in the resolve() method of the
 WebRequestCycleProcessor where I basically called setResponsePage() with
 the new parameter and threw a AbstractRestartResponseException().
 
  In Wicket 6 I was able to achieve the same by creating a custom Mapper
 that extends the MountedMapper.
  In this Mapper I added logic to the parseRequest method to check if the
 UrlInfo includes the parameter and if not create a new UrlInfo instance
 based on the original one that includes the parameter.
 
  This works but it requires that all pages are mounted with this specific
 Mapper.
 
  Is there a better way to add this logic so that it automatically applies
 to every request and does not require the developers to use the custom
 mapper?
 
  Thanks,
  Florian

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




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


Re: OnDomReadyHeaderItems

2013-02-26 Thread Martin Grigorov
Hi,

DomReady JS is executed manually in Ajax response:
1) execute prepend JS
2) replace components
3) execute ondomready
4) execute append JS

As Ernesto suggested you can use:

if (requestCycle.find(AjaxRequestTarget.class) == null) {
  response.render(OnDomReadyHeaderItem.forScript(...));
}


On Tue, Feb 26, 2013 at 11:33 PM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 I don't know if there is a better way... but can always check if you are
 NOT in a middle of and AJAX request cycle and if so contribute your script.


 On Tue, Feb 26, 2013 at 10:24 PM, Nick Pratt nbpr...@gmail.com wrote:

  With Wicket 6.5.0, is it expected that scripts added in
 Behavior.renderHead
  ( OnDomReadyHeaderItem.forScript( ... ); ) will be re-rendered and
 executed
  for partial DOM updates triggered via Ajax?
 
  If so, is there a way to add a Script to a Behavior such that it only
  renders on a full page re-render?
 
  N
 



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




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