Re: resource (css) loading

2010-04-11 Thread sahar rostami
Thanks so much dear apple grew!

Regards


On Sun, Apr 11, 2010 at 9:49 AM, Apple Grew appleg...@gmail.com wrote:

 Maybe it was stripped by Wicket Mailing list. Anyway I will paste the code
 in the mail itself.

 Regards,
 Apple Grew
 my blog @ http://blog.applegrew.com/

 --Code Starts--

 /**
  * Web based application for e-shopping.
  * Copyright (C) 2010  Nirupam Biswas (AppleGrew)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see http://www.gnu.org/licenses/.
  */
 package com.sym.core;

 import java.util.Arrays;
 import java.util.List;

 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.locator.ResourceStreamLocator;

 import com.sym.core.utils.MiscUtils;
 import com.sym.html.pages.BaseLayoutPage;

 public class AppStreamLocator extends ResourceStreamLocator {
private static final String HTML_EXT = .html;
private static final String CSS_EXT = .css;
private static final String JS_PATH = /js/;
private static final String CSS_PATH = /css/;
private static final String IMG_PATH = /img/;
private static final ListString IMG_EXTS = Arrays.asList(new String[]{
 .png, .jpg, .gif, .svg });

private static final String PAGES_PACKAGE =
 BaseLayoutPage.class.getPackage().getName();
private static final int PG_PACKAGE_NAME_LEN = PAGES_PACKAGE.length();
private static final int GLOBAL_PACKAGE_NAME_LEN =
 ApplicationCore.class.getPackage().getName().length();

@Override
public IResourceStream locate(final Class? clazz, String path) {
//Only pages' (not components or panel etc.s') HTMLs and CSS will be
 fetched from 'res' directory.
if(clazz.getName().startsWith(PAGES_PACKAGE)){
IResourceStream located = null;

if (path.endsWith(HTML_EXT) || path.endsWith(CSS_EXT)) {
located = super.locate(clazz, html/ +
 ApplicationCore.getThemeName() + trimFolders(path, false));
}else if (IMG_EXTS.contains(MiscUtils.getExt(path))) {
located = super.locate(clazz, /img + trimFolders(path,
 false));
}

if (located != null) {
return located;
}
}else if(clazz.equals(ApplicationCore.class)){
//Global shared resources have been requested.
IResourceStream located = null;
path = trimFolders(path, true);

if (path.startsWith(CSS_PATH) || path.startsWith(JS_PATH) ||
 path.startsWith(IMG_PATH)) {
located = super.locateByResourceFinder(clazz, path);
if(located == null  path.startsWith(CSS_PATH)) {
located = super.locateByResourceFinder(clazz,
CSS_PATH + ApplicationCore.getThemeName()
+ path.substring(path.indexOf(CSS_PATH) +
 CSS_PATH.length() - 1));
}
}
return located;
}
return super.locate(clazz, path);
}

private String trimFolders(final String path, final boolean
 isGlobalPath) {
return isGlobalPath? path.substring(GLOBAL_PACKAGE_NAME_LEN)
: path.substring(PG_PACKAGE_NAME_LEN);
}

 }


 --Code Ends--

 On Sun, Apr 11, 2010 at 9:18 AM, sahar rostami sahar.rost...@gmail.com
 wrote:

  thank you Apple Grew
  I can't receive your attachments. Are you sure they have been attached ?
 
  On Thu, Apr 8, 2010 at 6:34 AM, Apple Grew appleg...@gmail.com wrote:
 
   Maybe u can try writing a stream locator as I did. I am attaching my
  stream
   locator with this mail.
  
   The necessary plumbing required with this is:-
  
   resourceSettings.addResourceFolder(WEB-INF/res);
   resourceSettings.setResourceStreamLocator(new AppStreamLocator());
   getSharedResources().putClassAlias(ApplicationCore.class, global);
  
   The above needs to be put in your Application class.
  
   Regards,
   Apple Grew
   my blog @ http://blog.applegrew.com/
  
  
  
   On Wed, Apr 7, 2010 at 10:19 PM, Stefan Lindner lind...@visionet.de
  wrote:
  
   You could e.g. write your own page class
  
  class MyCustomersPage extens Page {
  @Override
  public void renderHead(HtmlHeaderContainer container) {
  super.renderHead(container);
  cssResourceReference =
   Session.get().getCssResourceReferenceForcustomer()
  
  
  

How to pass object as parameter to popup window

2010-04-11 Thread l yeung
Hi All,

I'm fairly new to Wicket, so forgive me if my question sound silly.

I've implemented a preview window by using bookmarkable page link and  popup
settings, very similar to Linkomatic from wicket examples:

-
PopupSettings popupSettings = new
PopupSettings(PageMap.forName(mypopuppagemap)).setHeight(
500).setWidth(500);
add(new BookmarkablePageLink(popupLink,
MyPage.class).setPopupSettings(popupSettings));


However, the issue that I face is that I need to pass an object as parameter
to MyPage, as this object is a class containing validated input values from
UI but not been persisted
 to db.

What would be the best way to implement this?

Thanks.

Cheers


Re: resource (css) loading

2010-04-11 Thread Apple Grew
u r welcome.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Sun, Apr 11, 2010 at 11:48 AM, sahar rostami sahar.rost...@gmail.comwrote:

 Thanks so much dear apple grew!

 Regards


 On Sun, Apr 11, 2010 at 9:49 AM, Apple Grew appleg...@gmail.com wrote:

  Maybe it was stripped by Wicket Mailing list. Anyway I will paste the
 code
  in the mail itself.
 
  Regards,
  Apple Grew
  my blog @ http://blog.applegrew.com/
 
  --Code Starts--
 
  /**
   * Web based application for e-shopping.
   * Copyright (C) 2010  Nirupam Biswas (AppleGrew)
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see http://www.gnu.org/licenses/.
   */
  package com.sym.core;
 
  import java.util.Arrays;
  import java.util.List;
 
  import org.apache.wicket.util.resource.IResourceStream;
  import org.apache.wicket.util.resource.locator.ResourceStreamLocator;
 
  import com.sym.core.utils.MiscUtils;
  import com.sym.html.pages.BaseLayoutPage;
 
  public class AppStreamLocator extends ResourceStreamLocator {
 private static final String HTML_EXT = .html;
 private static final String CSS_EXT = .css;
 private static final String JS_PATH = /js/;
 private static final String CSS_PATH = /css/;
 private static final String IMG_PATH = /img/;
 private static final ListString IMG_EXTS = Arrays.asList(new
 String[]{
  .png, .jpg, .gif, .svg });
 
 private static final String PAGES_PACKAGE =
  BaseLayoutPage.class.getPackage().getName();
 private static final int PG_PACKAGE_NAME_LEN = PAGES_PACKAGE.length();
 private static final int GLOBAL_PACKAGE_NAME_LEN =
  ApplicationCore.class.getPackage().getName().length();
 
 @Override
 public IResourceStream locate(final Class? clazz, String path) {
 //Only pages' (not components or panel etc.s') HTMLs and CSS will
 be
  fetched from 'res' directory.
 if(clazz.getName().startsWith(PAGES_PACKAGE)){
 IResourceStream located = null;
 
 if (path.endsWith(HTML_EXT) || path.endsWith(CSS_EXT)) {
 located = super.locate(clazz, html/ +
  ApplicationCore.getThemeName() + trimFolders(path, false));
 }else if (IMG_EXTS.contains(MiscUtils.getExt(path))) {
 located = super.locate(clazz, /img + trimFolders(path,
  false));
 }
 
 if (located != null) {
 return located;
 }
 }else if(clazz.equals(ApplicationCore.class)){
 //Global shared resources have been requested.
 IResourceStream located = null;
 path = trimFolders(path, true);
 
 if (path.startsWith(CSS_PATH) || path.startsWith(JS_PATH) ||
  path.startsWith(IMG_PATH)) {
 located = super.locateByResourceFinder(clazz, path);
 if(located == null  path.startsWith(CSS_PATH)) {
 located = super.locateByResourceFinder(clazz,
 CSS_PATH + ApplicationCore.getThemeName()
 + path.substring(path.indexOf(CSS_PATH) +
  CSS_PATH.length() - 1));
 }
 }
 return located;
 }
 return super.locate(clazz, path);
 }
 
 private String trimFolders(final String path, final boolean
  isGlobalPath) {
 return isGlobalPath? path.substring(GLOBAL_PACKAGE_NAME_LEN)
 : path.substring(PG_PACKAGE_NAME_LEN);
 }
 
  }
 
 
  --Code Ends--
 
  On Sun, Apr 11, 2010 at 9:18 AM, sahar rostami sahar.rost...@gmail.com
  wrote:
 
   thank you Apple Grew
   I can't receive your attachments. Are you sure they have been attached
 ?
  
   On Thu, Apr 8, 2010 at 6:34 AM, Apple Grew appleg...@gmail.com
 wrote:
  
Maybe u can try writing a stream locator as I did. I am attaching my
   stream
locator with this mail.
   
The necessary plumbing required with this is:-
   
resourceSettings.addResourceFolder(WEB-INF/res);
resourceSettings.setResourceStreamLocator(new AppStreamLocator());
getSharedResources().putClassAlias(ApplicationCore.class, global);
   
The above needs to be put in your Application class.
   
Regards,
Apple Grew
my blog @ http://blog.applegrew.com/
   
   
   
On Wed, Apr 7, 2010 at 10:19 PM, Stefan Lindner lind...@visionet.de
   wrote:
   
You could e.g. write your own page class
   
   class MyCustomersPage extens Page {

Re: FormTester with dynamic fields

2010-04-11 Thread Kent Tong


Anna Simbirtsev wrote:
 
 There is also an ADD MORE button, that adds more of those on the page.
 ...
 But that does not work.
 

If it is an AjaxButton, then WicketTester will not execute the Javascript.
To test the
effects as seen in the browser, you may try
http://wicketpagetest.sourceforge.net.


-
--
Kent Tong
Better way to unit test Wicket pages (http://wicketpagetest.sourceforge.net)
Books on CXF, Axis2, Wicket, JSF (http://agileskills2.org)
-- 
View this message in context: 
http://old.nabble.com/FormTester-with-dynamic-fields-tp28193951p28207809.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



problem with WicketTester to load template

2010-04-11 Thread Gustavo Henrique
hi guys!
I have been a problem using WicktTester. When I run a simple test, wicket
throws an exception because can't load the template html. But if I access
page via browser, wicket works fine.

the source code:

CustomerApplicationTest.java
http://pastebin.com/tRJ9hNuk

Example.java
http://pastebin.com/CW8BDPYE

ExampleTest.java
http://pastebin.com/uBBRAcSW

Example.html
html
body
input type=text wicket:id=username id=username
/body
/html

Thanks!


How do I provide digit-only IDs to make childs safe?

2010-04-11 Thread Alexandros Karypidis

Hi,

I'm a new Wicket user who is also getting familiar with the GMap2 module 
from wicket-stuff. I'm using the geocode example as a basis for 
creating a form which allows you to search for a location and set the 
map viewport to display it: 
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/geocode/


The code works, but every time I search for a place I get a warning:

WARN  - AbstractRepeater - Child component of repeater
org.apache.wicket.markup.repeater.RepeatingView:content
has a non-safe child id of [STRING_SEARCHED].
Safe child ids must be composed of digits only.

The [STRING_SEARCHED] is whatever I typed in the text field (e.g. 
Barcelona, Spain or Athens, Greece).


So apparently, GMap2 sets an ID somewhere using the text field's value, 
violating some Wicket expectation that such IDs should be composed using 
digits only.


How can I fix this?


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



Re: problem with WicketTester to load template

2010-04-11 Thread Per Newgro
 When I run a simple test, wicket throws an exception because can't 
load the template html.


Do you have a stacktrace?

Cheers
Per



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



How to centrally handle common exceptions from the databsae layer?

2010-04-11 Thread David Chang
I am hoping to understand how to write a good wicket app regarding handling 
exceptions from the databsae layer?

For a wickt form, I can have the following to handle user submission: 

@Override
protected void onSubmit() {
  User u = getModelObject();
  userDao.saveUser(u);
  setResponsePage(Results.class);
}

For a wikcet web app, I can have many forms.

But what is the best way to handle common database exceptions such as foreign 
key constraint violation, larger than a column width, etc. and displaying 
meaningful error messages? I could easily add try/catch around userDao#saveUser 
to handle them, but that would be bad in terms of code replication and 
maintenance. It may be good to handle in a central place.

How do you deal with this issue in your wicket apps?

Thanks for input!

Best. 




  

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



Scalability

2010-04-11 Thread François Meillet
Hi Wicketers,

1) I need to build a system which can perform
-6000 different users per day
and
-200 concurent users


The software used:

wicket
postgresql (mainly read operations)
hibernate
jms

At the beginning there will be 2 computers  (I prefer horizontal scalability).
What would be your advice for the hardware (hard drive will be 10.000 RPM).
-processor ?
-ram


2) Also I would appreciate your advice for the server:
I have the choice for the server: Tomcat + a JMS implementation like HornetQ, 
or Jboss Application Server. 
I hesitate between the 2 solutions, as I don't need EJBs, but we never know !!! 
. 

Have you any advice ?

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



Re: Scalability

2010-04-11 Thread Eelco Hillenius
2010/4/11 François Meillet fm...@meillet.com:
 Hi Wicketers,

 1) I need to build a system which can perform
 -6000 different users per day
 and
 -200 concurent users

I can very easily run that on my laptop.


 The software used:

 wicket
 postgresql (mainly read operations)
 hibernate
 jms

 At the beginning there will be 2 computers  (I prefer horizontal scalability).
 What would be your advice for the hardware (hard drive will be 10.000 RPM).
 -processor ?
 -ram

For 200 concurrent sessions, 100 MB is probably already enough (20MB
would be for sessions if you average 100K per session). But give your
VM 1GB or more and you should be able to handle a much larger peak
(600?) easily

 2) Also I would appreciate your advice for the server:
 I have the choice for the server: Tomcat + a JMS implementation like HornetQ, 
 or Jboss Application Server.
 I hesitate between the 2 solutions, as I don't need EJBs, but we never know 
 !!! .

If you don't need EJBs (and who would, I've always steered clear from
them and never regretted it), than don't worry about it. In the
unlikely case you ever do, just address it then by swapping out your
app server. Write your software generically enough so that you don't
depend on a single one.

If you know you need MQ and you want management of it integrated in
your application server, JBoss is worth considering. Also look at
Glassfish while you're at it.

Eelco

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



Re: Recover from session expiration ?

2010-04-11 Thread mbrictson

Have you seen jolira-tools? It was mentioned here on the mailing list
recently. I haven't used it, but it seems to have some components that are
intended solve the type of stateless ajax problem you are having.

http://code.google.com/p/jolira-tools/wiki/stateless


Boris Goldowsky-3 wrote:
 
 I have a wicket website that stores some user choices around how a page is
 displayed in the Session - simple, non-critical information.  It also uses
 Ajax to do things like bring up a zoomed-in version of an image.
 
 The problem is when sessions expire after an hour or so, trying to zoom an
 image or set a display preference causes an Page Expired exception.  Since
 people aren't logging in or anything, and no mission-critical information
 is being stored in the session, I'd prefer to allow a new session to be
 transparently created when necessary rather than showing users a session
 expired page.
 
 Am I missing some easy way around this problem, or do I need to re-build
 all the functionality to use cookies and jQuery instead of wicket forms
 and ajax?
 
 This thread seems relevant but didn't seem to have a solution:
 http://www.nabble.com/Graceful-handling-of-ajax-after-session-expiration-tf4559480.html
 
 Thanks for any pointers -
 
 Bng
 
 

-- 
View this message in context: 
http://old.nabble.com/Recover-from-session-expiration---tp28184196p28210705.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Recover from session expiration ?

2010-04-11 Thread mbrictson

Another option: include an AjaxSelfUpdatingTimerBehavior on your page; this
will keep your session from expiring.


Boris Goldowsky-3 wrote:
 
 I have a wicket website that stores some user choices around how a page is
 displayed in the Session - simple, non-critical information.  It also uses
 Ajax to do things like bring up a zoomed-in version of an image.
 
 The problem is when sessions expire after an hour or so, trying to zoom an
 image or set a display preference causes an Page Expired exception.  Since
 people aren't logging in or anything, and no mission-critical information
 is being stored in the session, I'd prefer to allow a new session to be
 transparently created when necessary rather than showing users a session
 expired page.
 
 Am I missing some easy way around this problem, or do I need to re-build
 all the functionality to use cookies and jQuery instead of wicket forms
 and ajax?
 
 This thread seems relevant but didn't seem to have a solution:
 http://www.nabble.com/Graceful-handling-of-ajax-after-session-expiration-tf4559480.html
 
 Thanks for any pointers -
 
 Bng
 
 

-- 
View this message in context: 
http://old.nabble.com/Recover-from-session-expiration---tp28184196p28210725.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: How do I provide digit-only IDs to make childs safe?

2010-04-11 Thread Sven Meier

Hi Alexandros,

it's just that the example uses the location's name as an id for a label 
shown as content in a GInfoWindowTab. See the following line

in the example:

  new GInfoWindowTab(address, new Label(*address*, address))

The label will end up inside a repeater which is complaining about the id.

Sven


Alexandros Karypidis wrote:

Hi,

I'm a new Wicket user who is also getting familiar with the GMap2 module 
from wicket-stuff. I'm using the geocode example as a basis for 
creating a form which allows you to search for a location and set the 
map viewport to display it: 
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/geocode/ 



The code works, but every time I search for a place I get a warning:

WARN  - AbstractRepeater - Child component of repeater
org.apache.wicket.markup.repeater.RepeatingView:content
has a non-safe child id of [STRING_SEARCHED].
Safe child ids must be composed of digits only.

The [STRING_SEARCHED] is whatever I typed in the text field (e.g. 
Barcelona, Spain or Athens, Greece).


So apparently, GMap2 sets an ID somewhere using the text field's value, 
violating some Wicket expectation that such IDs should be composed using 
digits only.


How can I fix this?


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




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



Re: Wicket and JEE6

2010-04-11 Thread Erik Brakkee
Just have a look at https://wamblee.org/svn/public/wicket-cdi
The main thing I did was to make the injection and caching stuff completely
independent of wicket and I made some arrangements to still allow unit tests
where you can inject different things from the defaults.

In particular, I think you can incorporate the InjectorCache in your design
and it would also be good to make the injection support independent of
wicket. Basically, the org.wamblee.cdi package tries to provide a simple and
efficient injection api (bean manager api is too general and too verbose for
most purposes)


Re: Wicket and JEE6

2010-04-11 Thread James Carman
I would imagine that most implementations would cache their injectors
(it's part of the BeanT)

On Sun, Apr 11, 2010 at 4:30 PM, Erik Brakkee erik.brak...@gmail.com wrote:
 Just have a look at https://wamblee.org/svn/public/wicket-cdi
 The main thing I did was to make the injection and caching stuff completely
 independent of wicket and I made some arrangements to still allow unit tests
 where you can inject different things from the defaults.

 In particular, I think you can incorporate the InjectorCache in your design
 and it would also be good to make the injection support independent of
 wicket. Basically, the org.wamblee.cdi package tries to provide a simple and
 efficient injection api (bean manager api is too general and too verbose for
 most purposes)


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



RE: Scalability

2010-04-11 Thread Chris Colman
 I hesitate between the 2 solutions, as I don't need EJBs, but we never
 know !!! .

If you have an app that currently doesn't need EJBs then keep it that
way!! ;)
 

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



Re: How to pass object as parameter to popup window

2010-04-11 Thread Mathias Nilsson

Session or pageParameters
-- 
View this message in context: 
http://old.nabble.com/How-to-pass-object-as-parameter-to-popup-window-tp28207456p28212525.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



RE: Scalability

2010-04-11 Thread Alan Garfield
On Mon, 2010-04-12 at 08:31 +1000, Chris Colman wrote:
  I hesitate between the 2 solutions, as I don't need EJBs, but we never
  know !!! .
 
 If you have an app that currently doesn't need EJBs then keep it that
 way!! ;)

More EJB FUD yay


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



Re: Any mature work on integrating Hibernate Validator with Wicket?

2010-04-11 Thread Ben Tilford
If you find anything useful heres some stuff I have put together
https://docs.google.com/leaf?id=0ByQjVcAVDuP9MWE4NDcxODMtODZlOC00Mzk0LThhOTUtYmI2MmNlYzEwNWFihl=en

I'd upload it somewhere else but it looks like there are already like 4
different projects for this.

2010/4/10 Uwe Schäfer u...@thomas-daily.de

 David Chang schrieb:

  hi, did you get the jsr 303 validation code released? where can i find it?
 i am really excited looking forward to it.


 about to. just finishing examples tomorrow. stay tuned.


 cu uwe

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