How to avoid code duplication on forms?

2009-05-08 Thread Christian Helmbold

Hello,

Wicket uses input validation on the presentation layer. This leads often to 
code duplication and I'm looking for a way to avoid it.

Example: I have a registration form where you fill in your first and last name, 
password and so on. Every field has its restrictions like max length or 
required. Registered users have a form for their personal information with 
additional fields. The password can be changed on a seperate page.

How can I avoid to double the programmtic configuration of the form fields? To 
extract and reuse panels is not an option, because of the different composition 
of the forms. 

a) I could create a subclass for every form field, but this would be a lot of 
writing.

b)I could create something like a FormFieldFactory:

public class UserFormFieldFactory
{
public static TextField createEmailField()
{
return new TextField(email)
.setRequired(true)
.add(EmailAddressValidator.getInstance())
.add(UniqueValidator.unique(SystemUser.class, email));
}

public static PasswordTextField createPasswordField()
{
...
}
...
}

c) ?

How do you avoid code duplication on forms?

Regards,
Christian




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



Re: How to avoid code duplication on forms?

2009-05-08 Thread Igor Vaynberg
much simpler

class UserEmailField extends TextField {
  public UserEmailField(String id, IModel model) {
super(id, model);
add(EmailAddressValidator.getInstance())
add(UniqueValidator.unique(SystemUser.class, email));
   }
}

-igor

On Thu, May 7, 2009 at 11:43 PM, Christian Helmbold
christian.helmb...@yahoo.de wrote:

 Hello,

 Wicket uses input validation on the presentation layer. This leads often to 
 code duplication and I'm looking for a way to avoid it.

 Example: I have a registration form where you fill in your first and last 
 name, password and so on. Every field has its restrictions like max length or 
 required. Registered users have a form for their personal information with 
 additional fields. The password can be changed on a seperate page.

 How can I avoid to double the programmtic configuration of the form fields? 
 To extract and reuse panels is not an option, because of the different 
 composition of the forms.

 a) I could create a subclass for every form field, but this would be a lot of 
 writing.

 b)I could create something like a FormFieldFactory:

 public class UserFormFieldFactory
 {
    public static TextField createEmailField()
    {
        return new TextField(email)
            .setRequired(true)
            .add(EmailAddressValidator.getInstance())
            .add(UniqueValidator.unique(SystemUser.class, email));
    }

    public static PasswordTextField createPasswordField()
    {
        ...
    }
    ...
 }

 c) ?

 How do you avoid code duplication on forms?

 Regards,
 Christian




 -
 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



Eelco's wicket-contrib-navmenu revival? OR: Doing menus in Wicket...

2009-05-08 Thread ralf . eichinger
under wicketstuff for 1.2 I found the little project wicket-contrib-navmenu.
I started to update it for Wicket 1.4-rc2.

Does this make sense or is there a better way to create hierarchy-like menues? 
Eelco?
I know there is a TabbedPanel component.
But I somehow feel strange to implement my whole application's pages as 
Panels...

So what is the best way to create the navigation for a big application
having an upper tab-navigation and a corresponding hierarchical tree-navigation 
on the left...

Wicket in Action did not address proper menu creation... ;-)

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



Re: Eelco's wicket-contrib-navmenu revival? OR: Doing menus in Wicket...

2009-05-08 Thread Ralf Eichinger


Martijn Dashorst wrote:
 
 Wicket in Action does discuss menus: see page 185 (index entry: menu),
 though not multilevel menus.
 
You are right, the easy way is described...


Martijn Dashorst wrote:
 
 Just take a look at YUI-menu or some jquery plugin for menus. The
 reason for not continuing the menu component is that there are enough
 alternatives available for rendering a menu. And most folks want their
 own styling, and a typical menu is nothing more than a couple of
 nested ul's with css.
 
Yes, menus should be nothing else than ul/li/a-trees styled with CSS.
But when I have a foldable menu, clicking a page link which
results in a new page (without ajax...), how can I restore the last
menu state folding and deactivating the active page's link?
(without cookies)

So is it the best to use wicket:link for the links (which takes care about
deactivating the link to the actual page) thrown into a hierarchically
ul/li/a-tree? That would leave the question open, how to unfold the tree to
the level where the active link resides...

-- 
View this message in context: 
http://www.nabble.com/Eelco%27s-wicket-contrib-navmenu-revival--OR%3A-Doing-menus-in-Wicket...-tp23441481p23442248.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: AjaxResponse with control characters is not validated

2009-05-08 Thread jensiator

done!


igor.vaynberg wrote:
 
 open a jira issue and add a quickstart please.
 
 -igor
 
 On Thu, May 7, 2009 at 4:12 AM, Jens Alenius jens.alen...@megasol.se
 wrote:
 Hi.
 Found something that might be a wicket ajax bug.
 This code wont work in Firefox and we believe that its the Ajax xml
 response
 that is invalid.
 The control characters is not properly escaped. Ex: \u0014 is written
 as
 0014 in the xml Ajax Response but should be #0014.
 See: http://www.w3.org/TR/REC-xml/#dt-charref.

 This code wont work in firefox

 Markup:
 ...
 div wicket:id=testValue/div
   form wicket:id=testform
   div wicket:id=testSubmit class=submitbuttonSubmit/div
 /form
 ...


       Java:
      
       final Label testLabel = new Label(testValue,themodel);
       testLabel.setOutputMarkupId(true);
       add(testLabel);
       FormString testForm = new FormString(testform);
       testForm.add(new AjaxButton(testSubmit){

           @Override
           protected void onSubmit(AjaxRequestTarget pTarget, Form?
 pForm)
 {
               themodel.setObject(\u0014);
                             pTarget.addComponent(testLabel);
           }                       });
       add(testForm);
       ...

 Jens Alenius


 -
 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
 
 
 

-- 
View this message in context: 
http://www.nabble.com/AjaxResponse-with-control-characters-is-not-validated-tp23424575p23442249.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: Eelco's wicket-contrib-navmenu revival? OR: Doing menus in Wicket...

2009-05-08 Thread Martijn Dashorst
Wicket in Action does discuss menus: see page 185 (index entry: menu),
though not multilevel menus.

Just take a look at YUI-menu or some jquery plugin for menus. The
reason for not continuing the menu component is that there are enough
alternatives available for rendering a menu. And most folks want their
own styling, and a typical menu is nothing more than a couple of
nested ul's with css.

Martijn

On Fri, May 8, 2009 at 10:24 AM,  ralf.eichin...@pixotec.de wrote:
 under wicketstuff for 1.2 I found the little project wicket-contrib-navmenu.
 I started to update it for Wicket 1.4-rc2.

 Does this make sense or is there a better way to create hierarchy-like 
 menues? Eelco?
 I know there is a TabbedPanel component.
 But I somehow feel strange to implement my whole application's pages as 
 Panels...

 So what is the best way to create the navigation for a big application
 having an upper tab-navigation and a corresponding hierarchical 
 tree-navigation on the left...

 Wicket in Action did not address proper menu creation... ;-)

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





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

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



SV: Wicket SWFObject

2009-05-08 Thread Wilhelmsen Tor Iver
 I just figured out that the deal is that SWFObject doesn't 
 like to be set visible false on page load then visible true via Ajax.
 
 Any thoughts on how to get around this?

Ajax in Wicket needs the page DOM to have an element with the id it is
supposed to replace with the output of a (now visible) component; by
default an invisible Wicket component has no output at all.

The traditional way to overcome this is to call
setOutputMarkupPlaceholderTag(true) on the (initially invisible)
component when you add it; that will make Wicket insert an empty element
with the required id. (It also implicitly calls setOutputMarkupId(true)
which is something else that the Ajax support needs to work properly.)

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



AW: How to avoid code duplication on forms?

2009-05-08 Thread Christian Helmbold

I think the difference between sub classing and static factory methods is a 
matter of taste in this case.

If I have many fields, I'd need many classes for them. So I'd group them in a 
sub package. In the case of factory methods I'd group the methods to create 
fields in a class instead of a package.

Subclass:

1class UserEmailField extends TextField {
2  public UserEmailField(String id, IModel model) {
3super(id, model);
4setRequired(true);
5add(EmailAddressValidator.getInstance())
6add(UniqueValidator.unique(SystemUser.class, email));
7  }
8}

Factory method:

1public static TextField emailTextField(String id){
2return (TextField) new TextField(id)
3.setRequired(true)
4.add(EmailAddressValidator.getInstance())
5.add(UniqueValidator.unique(SystemUser.class, email));
6}

Your answer shows me, that there is no dramatically simpler way to do this. If 
you ignore the two lines for factory class declaration factory methods are even 
a bit shorter. Or is there an advantage of sub classing that I have missed?

Regards,
Christian



- Ursprüngliche Mail 
 Von: Igor Vaynberg igor.vaynb...@gmail.com
 An: users@wicket.apache.org
 Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
 Betreff: Re: How to avoid code duplication on forms?
 
 much simpler
 
 class UserEmailField extends TextField {
   public UserEmailField(String id, IModel model) {
 super(id, model);
 add(EmailAddressValidator.getInstance())
 add(UniqueValidator.unique(SystemUser.class, email));
}
 }





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



Re: Spring Security's method security and Wicket

2009-05-08 Thread Kent Larsson
Hello,

Reference for this post:
http://forum.springsource.org/showthread.php?p=239559#post239559 (the
related Spring Security thread)

It actually seems my interpretation about how it might work was
correct below (though my original interpretation was wrong, but let's
not talk about that one ;-) ).

Luke Tayler mentions it might be Wicket swallowing the exception which
Spring Security creates and shows it to the user. That way Spring
Security will never know that the exception was thrown and it can't
redirect the user to the log in page.

What Spring Security seems to like doing is:

1. Spring Security records the request data.
2. When a @Secured(SOME_ROLE) annotated method is found it throws a
AuthenticationException or a AuthorizationException
3. This exception is cought by Spring Security which redirect the user
to the log in page.
4. When the user has logged on, the recorded request data is used
again to simulate the original request.

At step 2 above any transaction is rolled back.

Between step 2 and 3, at step 2.5 it seems Wicket catches the
AuthenticationException or AuthorizationException and (at least in
development mode) shows the exception to the user. That way step 3 and
4 will never be executed.

Between step 1 and 2, at step 1.5 above Wicket will do its stuff
(page, models, etc). If the same (recorded) request arrives again
(after user log in) how will Wicket react?

Is it possible to get this working with Wicket? Should I? Any tips?

I'm new to both Wicket and Spring Security, this might be a bit over
my head. It would be really nice to get it working though. Thank you
for reading! Have a nice weekend!

Best regards, Kent


On Wed, May 6, 2009 at 10:22 PM, Kent Larsson kent.lars...@gmail.com wrote:
 I don't know. I guess something like:

 1. Record the request data (like with URL interception) then let the
 method call fail  roll-back transactions
 2. Show log in page
 3. Play the recorded request and hope the call was determenistic

 But maybe I just misinterpreted him. Or maybe it would work with
 Spring MVC if they have this built into their architecture. But it
 sounds strange so I understand why you ask.

 Best regards, Kent


 On Wed, May 6, 2009 at 7:46 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 On Wed, May 6, 2009 at 10:25 AM, Kent Larsson kent.lars...@gmail.com wrote:
 2. At this point, the method call is intercepted by Spring and I
 _think_ I should get the option to log in here. However I do not get
 this option, instead I'm shown a stack trace.

 how is (2) accomplished?

 -igor



 I'm really banging my head against the wall here. I just wanted to ask
 here if this could have anything with the Wicket-Spring-IOC project?

 I would suspect no and that I'm to blame, but I'm also having a really
 hard time finding the source of the problem. If you have any tip for
 my as well I would really appreciate it! ;-)

 Best regards, Kent

 -
 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




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



Re: How to avoid code duplication on forms?

2009-05-08 Thread Marc Nuri (GMail)
Hi.
How about using varargs or a similar approach in your TextField:

code
public class ValidatedTextFieldT extends TextFieldT{
public ValidatedTextField(String id, final IModelT model, boolean
required, AbstractValidator... validators)
{
super(id, model);
setRequired(required);
for(AbstractValidator validator : validators){
add(validator);
}
}
}
/code

And the use case:

code
TextField t = new ValidatedTextField(id, new Model(your Model),
true,
EmailAddressValidator.getInstance(),
StringValidator.maximumLength(50));
/code

Maybe you could then use it in a class factory as you suggested. At least it
will shorten a few lines of code.
Best regards.
--
Marc Nuri
http://blog.marcnuri.com
On Fri, May 8, 2009 at 11:14 AM, Christian Helmbold 
christian.helmb...@yahoo.de wrote:


 I think the difference between sub classing and static factory methods is a
 matter of taste in this case.

 If I have many fields, I'd need many classes for them. So I'd group them in
 a sub package. In the case of factory methods I'd group the methods to
 create fields in a class instead of a package.

 Subclass:

 1class UserEmailField extends TextField {
 2  public UserEmailField(String id, IModel model) {
 3super(id, model);
 4setRequired(true);
 5add(EmailAddressValidator.getInstance())
 6add(UniqueValidator.unique(SystemUser.class, email));
 7  }
 8}

 Factory method:

 1public static TextField emailTextField(String id){
 2return (TextField) new TextField(id)
 3.setRequired(true)
 4.add(EmailAddressValidator.getInstance())
 5.add(UniqueValidator.unique(SystemUser.class,
 email));
 6}

 Your answer shows me, that there is no dramatically simpler way to do this.
 If you ignore the two lines for factory class declaration factory methods
 are even a bit shorter. Or is there an advantage of sub classing that I have
 missed?

 Regards,
 Christian



 - Ursprüngliche Mail 
  Von: Igor Vaynberg igor.vaynb...@gmail.com
  An: users@wicket.apache.org
  Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
  Betreff: Re: How to avoid code duplication on forms?
 
  much simpler
 
  class UserEmailField extends TextField {
public UserEmailField(String id, IModel model) {
  super(id, model);
  add(EmailAddressValidator.getInstance())
  add(UniqueValidator.unique(SystemUser.class, email));
 }
  }





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




Re: How to avoid code duplication on forms?

2009-05-08 Thread Martin Makundi
TextField t = new ValidatedTextField(id, new Model(your Model),

And remember to use Model.of(your Model)

**
Martin
http://tyoajanseuranta.blogit.fi/ Wicket työajanseuranta

 true,
EmailAddressValidator.getInstance(),
StringValidator.maximumLength(50));
 /code

 Maybe you could then use it in a class factory as you suggested. At least it
 will shorten a few lines of code.
 Best regards.
 --
 Marc Nuri
 http://blog.marcnuri.com
 On Fri, May 8, 2009 at 11:14 AM, Christian Helmbold 
 christian.helmb...@yahoo.de wrote:


 I think the difference between sub classing and static factory methods is a
 matter of taste in this case.

 If I have many fields, I'd need many classes for them. So I'd group them in
 a sub package. In the case of factory methods I'd group the methods to
 create fields in a class instead of a package.

 Subclass:

 1class UserEmailField extends TextField {
 2  public UserEmailField(String id, IModel model) {
 3super(id, model);
 4setRequired(true);
 5add(EmailAddressValidator.getInstance())
 6add(UniqueValidator.unique(SystemUser.class, email));
 7  }
 8}

 Factory method:

 1public static TextField emailTextField(String id){
 2return (TextField) new TextField(id)
 3.setRequired(true)
 4.add(EmailAddressValidator.getInstance())
 5.add(UniqueValidator.unique(SystemUser.class,
 email));
 6}

 Your answer shows me, that there is no dramatically simpler way to do this.
 If you ignore the two lines for factory class declaration factory methods
 are even a bit shorter. Or is there an advantage of sub classing that I have
 missed?

 Regards,
 Christian



 - Ursprüngliche Mail 
  Von: Igor Vaynberg igor.vaynb...@gmail.com
  An: users@wicket.apache.org
  Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
  Betreff: Re: How to avoid code duplication on forms?
 
  much simpler
 
  class UserEmailField extends TextField {
public UserEmailField(String id, IModel model) {
  super(id, model);
  add(EmailAddressValidator.getInstance())
  add(UniqueValidator.unique(SystemUser.class, email));
 }
  }





 -
 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



RadioGroup with Boolean Model

2009-05-08 Thread Christoph Grün
Hello,

 

I want to have a radio group that looks like this:

 

How do I have to set the model of the Radio Group? Must this be a Boolean
one and what is set with getObject and setObject methods?

 

input name=radiogroup wicket:id=field1 type=radio
id=radiogroup13-field114 value=radio10 checked=checked/

input name=radiogroup wicket:id=field2 type=radio
id=radiogroup13-field215 value=radio11/

 

  RadioGroup groupOne = new RadioGroup(radiogroup, new ModelBoolean() {

@Override

public Boolean getObject() {

}

 

@Override

public void setObject(Boolean object) {

}

}

);

groupOne.add(new Radio(field1, new Model(new Boolean(true;

groupOne.add(new Radio(field2, new ModelBoolean() {

@Override

public Boolean getObject() {

return false;.

}

 

@Override

public void setObject(Boolean object) {

if (object) {

//set object

}

}

}

));

 

 



Re: Spring Security's method security and Wicket

2009-05-08 Thread James Carman
You can check out my wicket-advanced application that I wrote for a
talk I gave to our local Java users group.  In there, I implemented a
Spring Security-based implementation.  Here's my session class:

http://svn.carmanconsulting.com/public/wicket-advanced/trunk/src/main/java/com/carmanconsulting/wicket/advanced/web/common/session/SpringSecuritySession.java

and here's my application class:

http://svn.carmanconsulting.com/public/wicket-advanced/trunk/src/main/java/com/carmanconsulting/wicket/advanced/web/common/application/WicketApplication.java

and here's my web configuration:

http://svn.carmanconsulting.com/public/wicket-advanced/trunk/src/main/webapp/WEB-INF/web.xml

and here's my spring configuration:

http://svn.carmanconsulting.com/public/wicket-advanced/trunk/src/main/resources/META-INF/beans.xml

It works, but I believe someone pointed out a little bit of a bug in
my code at one point.  I don't think I fixed it yet.  I can't remember
who it was.  Anyone?  Perhaps it was something about not catching the
authentication exception in the login and returning false?  I can't
remember. :(


On Fri, May 8, 2009 at 5:51 AM, Kent Larsson kent.lars...@gmail.com wrote:
 Hello,

 Reference for this post:
 http://forum.springsource.org/showthread.php?p=239559#post239559 (the
 related Spring Security thread)

 It actually seems my interpretation about how it might work was
 correct below (though my original interpretation was wrong, but let's
 not talk about that one ;-) ).

 Luke Tayler mentions it might be Wicket swallowing the exception which
 Spring Security creates and shows it to the user. That way Spring
 Security will never know that the exception was thrown and it can't
 redirect the user to the log in page.

 What Spring Security seems to like doing is:

 1. Spring Security records the request data.
 2. When a @Secured(SOME_ROLE) annotated method is found it throws a
 AuthenticationException or a AuthorizationException
 3. This exception is cought by Spring Security which redirect the user
 to the log in page.
 4. When the user has logged on, the recorded request data is used
 again to simulate the original request.

 At step 2 above any transaction is rolled back.

 Between step 2 and 3, at step 2.5 it seems Wicket catches the
 AuthenticationException or AuthorizationException and (at least in
 development mode) shows the exception to the user. That way step 3 and
 4 will never be executed.

 Between step 1 and 2, at step 1.5 above Wicket will do its stuff
 (page, models, etc). If the same (recorded) request arrives again
 (after user log in) how will Wicket react?

 Is it possible to get this working with Wicket? Should I? Any tips?

 I'm new to both Wicket and Spring Security, this might be a bit over
 my head. It would be really nice to get it working though. Thank you
 for reading! Have a nice weekend!

 Best regards, Kent


 On Wed, May 6, 2009 at 10:22 PM, Kent Larsson kent.lars...@gmail.com wrote:
 I don't know. I guess something like:

 1. Record the request data (like with URL interception) then let the
 method call fail  roll-back transactions
 2. Show log in page
 3. Play the recorded request and hope the call was determenistic

 But maybe I just misinterpreted him. Or maybe it would work with
 Spring MVC if they have this built into their architecture. But it
 sounds strange so I understand why you ask.

 Best regards, Kent


 On Wed, May 6, 2009 at 7:46 PM, Igor Vaynberg igor.vaynb...@gmail.com 
 wrote:
 On Wed, May 6, 2009 at 10:25 AM, Kent Larsson kent.lars...@gmail.com 
 wrote:
 2. At this point, the method call is intercepted by Spring and I
 _think_ I should get the option to log in here. However I do not get
 this option, instead I'm shown a stack trace.

 how is (2) accomplished?

 -igor



 I'm really banging my head against the wall here. I just wanted to ask
 here if this could have anything with the Wicket-Spring-IOC project?

 I would suspect no and that I'm to blame, but I'm also having a really
 hard time finding the source of the problem. If you have any tip for
 my as well I would really appreciate it! ;-)

 Best regards, Kent

 -
 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




 -
 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: How to avoid code duplication on forms?

2009-05-08 Thread Gabriel Kastenbaum
If the fields (user/pwd) always go together on every pages, why not having
having one root Panel (called MyPanel) knowing the fields , validation etc
and several Panels that simply extends MyPanel  ; avec each child has its
own layouts.

Best regards,
Gabriel Kastenbaum
http://blog.oxiane.com

2009/5/8 Martin Makundi martin.maku...@koodaripalvelut.com

 TextField t = new ValidatedTextField(id, new Model(your
 Model),

 And remember to use Model.of(your Model)

 **
 Martin
 http://tyoajanseuranta.blogit.fi/ Wicket työajanseuranta

  true,
 EmailAddressValidator.getInstance(),
 StringValidator.maximumLength(50));
  /code
 
  Maybe you could then use it in a class factory as you suggested. At least
 it
  will shorten a few lines of code.
  Best regards.
  --
  Marc Nuri
  http://blog.marcnuri.com
  On Fri, May 8, 2009 at 11:14 AM, Christian Helmbold 
  christian.helmb...@yahoo.de wrote:
 
 
  I think the difference between sub classing and static factory methods
 is a
  matter of taste in this case.
 
  If I have many fields, I'd need many classes for them. So I'd group them
 in
  a sub package. In the case of factory methods I'd group the methods to
  create fields in a class instead of a package.
 
  Subclass:
 
  1class UserEmailField extends TextField {
  2  public UserEmailField(String id, IModel model) {
  3super(id, model);
  4setRequired(true);
  5add(EmailAddressValidator.getInstance())
  6add(UniqueValidator.unique(SystemUser.class, email));
  7  }
  8}
 
  Factory method:
 
  1public static TextField emailTextField(String id){
  2return (TextField) new TextField(id)
  3.setRequired(true)
  4.add(EmailAddressValidator.getInstance())
  5.add(UniqueValidator.unique(SystemUser.class,
  email));
  6}
 
  Your answer shows me, that there is no dramatically simpler way to do
 this.
  If you ignore the two lines for factory class declaration factory
 methods
  are even a bit shorter. Or is there an advantage of sub classing that I
 have
  missed?
 
  Regards,
  Christian
 
 
 
  - Ursprüngliche Mail 
   Von: Igor Vaynberg igor.vaynb...@gmail.com
   An: users@wicket.apache.org
   Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
   Betreff: Re: How to avoid code duplication on forms?
  
   much simpler
  
   class UserEmailField extends TextField {
 public UserEmailField(String id, IModel model) {
   super(id, model);
   add(EmailAddressValidator.getInstance())
   add(UniqueValidator.unique(SystemUser.class, email));
  }
   }
 
 
 
 
 
  -
  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: yui slider component does not work

2009-05-08 Thread Joshua Lim
Hi Christoph

This was due to YuiHeaderContributor being moved to another package. I was
doing some house keeping :p

it should be fixed in /yui/ trunk now (no change in yui-examples).

can you try again?

Joshua

2009/5/5 Christoph Grün chris...@gmx.at

 Hello,



 I have downloaded the yui-examples-1.4-20090427.160726-141.war file.



 The sliders cannot be moved with the mouse and rather behave static.
 Moreover, the javascript error “yahoo.widget.slider is null” is reported.



 It seems that some js files are missing.



 Is there a workaround/update?



 Best regards,

 Christoph




AW: yui slider component does not work

2009-05-08 Thread Christoph Grün
Hi Joshua!

Thanks a lot!!
It works.

Christoph



-Ursprüngliche Nachricht-
Von: Joshua Lim [mailto:lim.j...@gmail.com] 
Gesendet: Freitag, 08. Mai 2009 13:45
An: users@wicket.apache.org
Betreff: Re: yui slider component does not work

Hi Christoph

This was due to YuiHeaderContributor being moved to another package. I was
doing some house keeping :p

it should be fixed in /yui/ trunk now (no change in yui-examples).

can you try again?

Joshua

2009/5/5 Christoph Grün chris...@gmx.at

 Hello,



 I have downloaded the yui-examples-1.4-20090427.160726-141.war file.



 The sliders cannot be moved with the mouse and rather behave static.
 Moreover, the javascript error “yahoo.widget.slider is null” is reported.



 It seems that some js files are missing.



 Is there a workaround/update?



 Best regards,

 Christoph




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



Re: AW: How to avoid code duplication on forms?

2009-05-08 Thread Jonathan Locke


the advantage to subclassing is that you're working better with the type
system whereas static pulls you out of the object world and should be used
with great caution.  for example, subclassing enables more subclassing and
therefore more reusability. static factory methods cannot be specialized.  i
also feel it's more intuitive to users for something like this. if you want
to see all the textfields on your project and you subclass textfield, you
can bring up textfield and hit F4 in eclipse and see the class hierarchy.
static factory methods are a bit more hidden to quick inspection. i like
static factory methods for things like units (Distance.meters(...) versus
Distance.feet(...)) or if you want to vary the subclass returned.

one improvement i'd make:

   public class EmailField extends TextField

and write an EmailConverter.  another reason subclassing is best.


Christian Helmbold-2 wrote:
 
 
 I think the difference between sub classing and static factory methods is
 a matter of taste in this case.
 
 If I have many fields, I'd need many classes for them. So I'd group them
 in a sub package. In the case of factory methods I'd group the methods to
 create fields in a class instead of a package.
 
 Subclass:
 
 1class UserEmailField extends TextField {
 2  public UserEmailField(String id, IModel model) {
 3super(id, model);
 4setRequired(true);
 5add(EmailAddressValidator.getInstance())
 6add(UniqueValidator.unique(SystemUser.class, email));
 7  }
 8}
 
 Factory method:
 
 1public static TextField emailTextField(String id){
 2return (TextField) new TextField(id)
 3.setRequired(true)
 4.add(EmailAddressValidator.getInstance())
 5.add(UniqueValidator.unique(SystemUser.class,
 email));
 6}
 
 Your answer shows me, that there is no dramatically simpler way to do
 this. If you ignore the two lines for factory class declaration factory
 methods are even a bit shorter. Or is there an advantage of sub classing
 that I have missed?
 
 Regards,
 Christian
 
 
 
 - Ursprüngliche Mail 
 Von: Igor Vaynberg igor.vaynb...@gmail.com
 An: users@wicket.apache.org
 Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
 Betreff: Re: How to avoid code duplication on forms?
 
 much simpler
 
 class UserEmailField extends TextField {
   public UserEmailField(String id, IModel model) {
 super(id, model);
 add(EmailAddressValidator.getInstance())
 add(UniqueValidator.unique(SystemUser.class, email));
}
 }
 
 
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-avoid-code-duplication-on-forms--tp23440920p23445544.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: AW: How to avoid code duplication on forms?

2009-05-08 Thread Jonathan Locke


the advantage to subclassing is that you're working better with the type
system whereas static pulls you out of the object world and should be used
with great caution.  for example, subclassing enables more subclassing and
therefore more reusability. static factory methods cannot be specialized.  i
also feel it's more intuitive to users for something like this. if you want
to see all the textfields on your project and you subclass textfield, you
can bring up textfield and hit F4 in eclipse and see the class hierarchy.
static factory methods are a bit more hidden to quick inspection. i like
static factory methods for things like units (Distance.meters(...) versus
Distance.feet(...)) or if you want to vary the subclass returned.

one improvement i'd make:

   public class EmailField extends TextField

and write an EmailConverter.  another reason subclassing is best.


Christian Helmbold-2 wrote:
 
 
 I think the difference between sub classing and static factory methods is
 a matter of taste in this case.
 
 If I have many fields, I'd need many classes for them. So I'd group them
 in a sub package. In the case of factory methods I'd group the methods to
 create fields in a class instead of a package.
 
 Subclass:
 
 1class UserEmailField extends TextField {
 2  public UserEmailField(String id, IModel model) {
 3super(id, model);
 4setRequired(true);
 5add(EmailAddressValidator.getInstance())
 6add(UniqueValidator.unique(SystemUser.class, email));
 7  }
 8}
 
 Factory method:
 
 1public static TextField emailTextField(String id){
 2return (TextField) new TextField(id)
 3.setRequired(true)
 4.add(EmailAddressValidator.getInstance())
 5.add(UniqueValidator.unique(SystemUser.class,
 email));
 6}
 
 Your answer shows me, that there is no dramatically simpler way to do
 this. If you ignore the two lines for factory class declaration factory
 methods are even a bit shorter. Or is there an advantage of sub classing
 that I have missed?
 
 Regards,
 Christian
 
 
 
 - Ursprüngliche Mail 
 Von: Igor Vaynberg igor.vaynb...@gmail.com
 An: users@wicket.apache.org
 Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
 Betreff: Re: How to avoid code duplication on forms?
 
 much simpler
 
 class UserEmailField extends TextField {
   public UserEmailField(String id, IModel model) {
 super(id, model);
 add(EmailAddressValidator.getInstance())
 add(UniqueValidator.unique(SystemUser.class, email));
}
 }
 
 
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-avoid-code-duplication-on-forms--tp23440920p23445543.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: AW: How to avoid code duplication on forms?

2009-05-08 Thread Jonathan Locke


uh that was:

class EmailField extends TextField[Email]

where the square brackets are angle brackets :)


Christian Helmbold-2 wrote:
 
 
 I think the difference between sub classing and static factory methods is
 a matter of taste in this case.
 
 If I have many fields, I'd need many classes for them. So I'd group them
 in a sub package. In the case of factory methods I'd group the methods to
 create fields in a class instead of a package.
 
 Subclass:
 
 1class UserEmailField extends TextField {
 2  public UserEmailField(String id, IModel model) {
 3super(id, model);
 4setRequired(true);
 5add(EmailAddressValidator.getInstance())
 6add(UniqueValidator.unique(SystemUser.class, email));
 7  }
 8}
 
 Factory method:
 
 1public static TextField emailTextField(String id){
 2return (TextField) new TextField(id)
 3.setRequired(true)
 4.add(EmailAddressValidator.getInstance())
 5.add(UniqueValidator.unique(SystemUser.class,
 email));
 6}
 
 Your answer shows me, that there is no dramatically simpler way to do
 this. If you ignore the two lines for factory class declaration factory
 methods are even a bit shorter. Or is there an advantage of sub classing
 that I have missed?
 
 Regards,
 Christian
 
 
 
 - Ursprüngliche Mail 
 Von: Igor Vaynberg igor.vaynb...@gmail.com
 An: users@wicket.apache.org
 Gesendet: Freitag, den 8. Mai 2009, 09:08:34 Uhr
 Betreff: Re: How to avoid code duplication on forms?
 
 much simpler
 
 class UserEmailField extends TextField {
   public UserEmailField(String id, IModel model) {
 super(id, model);
 add(EmailAddressValidator.getInstance())
 add(UniqueValidator.unique(SystemUser.class, email));
}
 }
 
 
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-avoid-code-duplication-on-forms--tp23440920p23445578.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



AjaxTabbedPanel custom validation behaviour

2009-05-08 Thread Alfredo Aleandri
I'm using an AjaxTabbedPanel and I would like to obtain the following 
behaviours:


1) user input must be retained when switching tabs

2) tabs link should skip only the requireness validation but not all 
other validators so the user can switch from tab to tab if he doesn't 
insert bad input


3) a submit button present in all tabs should execute a full validation 
of the TabbedPanel (all tabs) before execute some logic on the user input



Actually I've solved the point 1 overriding the AjaxTabbedPanel#newLink 
returning an AjaxSubmitLink instead the AjaxFallbackLink.

What is the best way to solve the other two open points?

Thank you

The relevant code of my WebPage follow:

||

public TabbedPanelPage() {

   final Form form = new Form(formy, new CompoundPropertyModel(this));

   form.setOutputMarkupId(true);
   add(form);

   final FeedbackPanel fp = new FeedbackPanel(feedback);
   fp.setOutputMarkupId(true);
   add(fp);

List tabs = new ArrayList();
tabs.add(new AbstractTab(new Model(first tab)) {
public Panel getPanel(String panelId) {
Panel p = new TabPanel1(panelId, form.getModel());
firstNameText = new TextField(text1);
firstNameText.setOutputMarkupId(true);
firstNameText.add(new 
StringValidator.MinimumLengthValidator(2));
p.add(firstNameText);
return p;
}
});
   
tabs.add(new AbstractTab(new Model(second tab)) {

public Panel getPanel(String panelId) {
Panel p = new TabPanel2(panelId, form.getModel());
lastNameText = new TextField(text2);
lastNameText.add(new StringValidator.MinimumLengthValidator(2));
p.add(lastNameText);
return p;
}
});   
 
tabPanel = new AjaxTabbedPanel(tabs, tabs) {

@Override
protected WebMarkupContainer newLink(String linkId, final int 
index) {

return new AjaxSubmitLink(linkId, form) {

private static final long serialVersionUID = 1L;
   
@Override

protected void onSubmit(AjaxRequestTarget target, Form 
form) {
setSelectedTab(index);
if (target != null) {
target.addComponent(form);
}
onAjaxUpdate(target);
}
   
@Override

protected void onError(AjaxRequestTarget target, Form form){
target.addComponent(fp);
}
}.setDefaultFormProcessing(true);
}
};
form.add(tabPanel);
 
Button submit = new Button(submit_button) {

@Override
public void onSubmit() {

   // TODO - validate entire form and process data

}
};
form.add(submit);
   }





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



Re: AjaxTabbedPanel custom validation behaviour

2009-05-08 Thread Igor Vaynberg
when used with forms it is a better idea to output the entire form and
use javascript tabs.

-igor

On Fri, May 8, 2009 at 6:11 AM, Alfredo Aleandri
alfredo.alean...@logobject.ch wrote:
 I'm using an AjaxTabbedPanel and I would like to obtain the following
 behaviours:

 1) user input must be retained when switching tabs

 2) tabs link should skip only the requireness validation but not all other
 validators so the user can switch from tab to tab if he doesn't insert bad
 input

 3) a submit button present in all tabs should execute a full validation of
 the TabbedPanel (all tabs) before execute some logic on the user input


 Actually I've solved the point 1 overriding the AjaxTabbedPanel#newLink
 returning an AjaxSubmitLink instead the AjaxFallbackLink.
 What is the best way to solve the other two open points?

 Thank you

 The relevant code of my WebPage follow:

 ||

 public TabbedPanelPage() {
               final Form form = new Form(formy, new
 CompoundPropertyModel(this));
       form.setOutputMarkupId(true);
       add(form);

       final FeedbackPanel fp = new FeedbackPanel(feedback);
       fp.setOutputMarkupId(true);
       add(fp);

        List tabs = new ArrayList();
        tabs.add(new AbstractTab(new Model(first tab)) {
            public Panel getPanel(String panelId) {
                Panel p = new TabPanel1(panelId, form.getModel());
                firstNameText = new TextField(text1);
                firstNameText.setOutputMarkupId(true);
                firstNameText.add(new
 StringValidator.MinimumLengthValidator(2));
                p.add(firstNameText);
                return p;
            }
        });
          tabs.add(new AbstractTab(new Model(second tab)) {
            public Panel getPanel(String panelId) {
                Panel p = new TabPanel2(panelId, form.getModel());
                lastNameText = new TextField(text2);
                lastNameText.add(new
 StringValidator.MinimumLengthValidator(2));
                p.add(lastNameText);
                return p;
            }
        });              tabPanel = new AjaxTabbedPanel(tabs, tabs) {
           �...@override
            protected WebMarkupContainer newLink(String linkId, final int
 index) {
                                return new AjaxSubmitLink(linkId, form) {
                    private static final long serialVersionUID = 1L;
                     �...@override
                    protected void onSubmit(AjaxRequestTarget target, Form
 form) {
                        setSelectedTab(index);
                        if (target != null) {
                            target.addComponent(form);
                        }
                        onAjaxUpdate(target);
                    }
                     �...@override
                    protected void onError(AjaxRequestTarget target, Form
 form){
                        target.addComponent(fp);
                    }
                }.setDefaultFormProcessing(true);
            }
        };
        form.add(tabPanel);
            Button submit = new Button(submit_button) {
           �...@override
            public void onSubmit() {
                               // TODO - validate entire form and process
 data
            }
        };
        form.add(submit);
   }





 -
 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



Object without ID in LoadableDetachableModels

2009-05-08 Thread Christian Helmbold

Domain (or model) objects get their IDs from Hibernate on saving in my 
application. When I create a new LoadableDetachableModel with a fresh model 
object without an ID, the LoadableDetachableModel object contains no ID to load 
the model object from the DB on the next request.

Because LoadableDetachableModel is read-only, I can not set an ID like in the 
hand made detachable model in Wicket in Action on Page 99, where the ID is 
set in setObject(Object o). Do I have to create a new LoadableDetachableModel 
after the initial saving of the domain object and then replace the old 
LoadableDetachableModel object with it?

Tanks,
Christian




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



Re: Object without ID in LoadableDetachableModels

2009-05-08 Thread James Carman
Can you switch to using UUIDs?  That saved me a LOT of headaches!

On Fri, May 8, 2009 at 11:21 AM, Christian Helmbold
christian.helmb...@yahoo.de wrote:

 Domain (or model) objects get their IDs from Hibernate on saving in my 
 application. When I create a new LoadableDetachableModel with a fresh model 
 object without an ID, the LoadableDetachableModel object contains no ID to 
 load the model object from the DB on the next request.

 Because LoadableDetachableModel is read-only, I can not set an ID like in the 
 hand made detachable model in Wicket in Action on Page 99, where the ID 
 is set in setObject(Object o). Do I have to create a new 
 LoadableDetachableModel after the initial saving of the domain object and 
 then replace the old LoadableDetachableModel object with it?

 Tanks,
 Christian




 -
 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: best way to add tooltips in wicket

2009-05-08 Thread nino martinez wael
very strange i'll look into it soon, when I get the app thats gonna
use it up to 1.4

2009/5/7 RoyBatty math...@afjochnick.net:

 Thanks Nino.

 A little bit more input on the Mootip performance bit, if you're interested.
 Basically, when we're using it it behaves quite differently from the mootip
 examples you can see on their page.

 here's what happens:

 When a Mootip is added to, for example, a label, and you drag the mouse
 pointer reeally slowly over it, the tip shows up, then when the mouse
 comes to the next pixel, it disappears, then appears/disappears for every
 other pixel that the mouse moves across!

 If you check with Firebug, you can see that the div visibility settings are
 changed as you move the mouse across.

 Really funky, and i have no idea why it behaves like that :)



 Hi Roy

 Regarding 1. You should be able to tweak settings as you want theres a
 showdelay setting you can setup. And a lot more settings regarding
 timeout etc if wanted..

 Regarding 2:
 No it seems it has to have a title at least my wrappers, you could try
 to set maxTitleChars to 0, int the mootip settings..

 I just did'nt see the need for not having a title when I created it :)

 --
 View this message in context: 
 http://www.nabble.com/best-way-to-add-tooltips-in-wicket-tp22697930p23422027.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



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



Re: Object without ID in LoadableDetachableModels

2009-05-08 Thread Igor Vaynberg
http://wicketinaction.com/2008/09/building-a-smart-entitymodel/

-igor

On Fri, May 8, 2009 at 8:21 AM, Christian Helmbold
christian.helmb...@yahoo.de wrote:

 Domain (or model) objects get their IDs from Hibernate on saving in my 
 application. When I create a new LoadableDetachableModel with a fresh model 
 object without an ID, the LoadableDetachableModel object contains no ID to 
 load the model object from the DB on the next request.

 Because LoadableDetachableModel is read-only, I can not set an ID like in the 
 hand made detachable model in Wicket in Action on Page 99, where the ID 
 is set in setObject(Object o). Do I have to create a new 
 LoadableDetachableModel after the initial saving of the domain object and 
 then replace the old LoadableDetachableModel object with it?

 Tanks,
 Christian




 -
 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



60% waste

2009-05-08 Thread Martin Makundi
Hi!

I use TDD: I spend 60% of my time type-checking and path-checking my
wicketTests and components.

I always have the wrong path and I must prinDocument and iterate to
get it right

Anybody have the same experience?

How about introducing type-safety and path-safety/identity into
component hierarchies?

Can this be done?

**
Martin

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



Re: 60% waste

2009-05-08 Thread Martijn Dashorst
See jdave-wicket for better test support. Slated to come to you in Wicket 1.5

Martijn

On Fri, May 8, 2009 at 5:48 PM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 Hi!

 I use TDD: I spend 60% of my time type-checking and path-checking my
 wicketTests and components.

 I always have the wrong path and I must prinDocument and iterate to
 get it right

 Anybody have the same experience?

 How about introducing type-safety and path-safety/identity into
 component hierarchies?

 Can this be done?

 **
 Martin

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





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

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



Re: 60% waste

2009-05-08 Thread Andrea Aime

Martin Makundi ha scritto:

Hi!

I use TDD: I spend 60% of my time type-checking and path-checking my
wicketTests and components.

I always have the wrong path and I must prinDocument and iterate to
get it right


I don't know if this is of any help, but I've written the attached
utility class that, given a component, can print its containment
structure, along with the eventual component classes and
model values (toString-ed).

I find it useful to quickly visualize the current component hierarchy
while writing tests and debugging.

Hope this helps

Cheers
Andrea




import java.io.PrintStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.regex.Pattern;

import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.Page;

/**
 * Dumps a wicket component/page hierarchy to text, eventually writing 
down the class and the model

 * value as a string.
 * p
 * Each line in the dump follow the codecomponentId(class) 
'value'/code format.

 * /p
 * p
 * The class can be reused for multiple prints, but it's not thread safe
 * /p
 */
public class WicketHierarchyPrinter {
static final Pattern NEWLINE = Pattern.compile(\\n, 
Pattern.MULTILINE);


PrintStream out;

boolean valueDumpEnabled;

boolean classDumpEnabled;

/**
 * Utility method to dump a single component/page to standard output
 * @param c
 * @param dumpClass
 * @param dumpValue
 */
public static void print(Component c, boolean dumpClass, boolean 
dumpValue) {

WicketHierarchyPrinter printer = new WicketHierarchyPrinter();
printer.setClassDumpEnabled(dumpClass);
printer.setValueDumpEnabled(dumpValue);
if(c instanceof Page) {
printer.print((Page) c);
} else {
printer.print(c);
}
}

/**
 * Creates a printer that will dump to standard output
 */
public WicketHierarchyPrinter() {
out = System.out;
}

/**
 * Creates a printer that will dump to the specified print stream
 */
public WicketHierarchyPrinter(PrintStream out) {
this.out = out;
}

/**
 * Set to true if you want to see the model values in the dump
 *
 * @param valueDumpEnabled
 */
public void setValueDumpEnabled(boolean valueDumpEnabled) {
this.valueDumpEnabled = valueDumpEnabled;
}

/**
 * Set to true if you want to see the component classes in the dump
 *
 * @param classDumpEnabled
 */
public void setClassDumpEnabled(boolean classDumpEnabled) {
this.classDumpEnabled = classDumpEnabled;
}

/**
 * Prints the component containment hierarchy
 *
 * @param c
 */
public void print(Component c) {
walkHierarchy(c, 0);
}

/**
 * Walks down the containment hierarchy depth first and prints each 
component found

 */
private void walkHierarchy(Component c, int level) {
printComponent(c, level);
if (c instanceof MarkupContainer) {
MarkupContainer mc = (MarkupContainer) c;
for (Iterator it = mc.iterator(); it.hasNext();) {
walkHierarchy((Component) it.next(), level + 1);
}
}
}

/**
 * Prints a single component
 */
private void printComponent(Component c, int level) {
if(c instanceof Page)
out.print(tab(level) + PAGE_ROOT);
else
out.print(tab(level) + c.getId());

if (classDumpEnabled) {
String className;
if(c.getClass().isAnonymousClass()) {
className = c.getClass().getSuperclass().getName();
} else {
className = c.getClass().getName();
}

out.print(( + className + ));
}

if (valueDumpEnabled) {
try {
String value = 
NEWLINE.matcher(c.getModelObjectAsString()).replaceAll(n);

out.print( ' + value + ');
} catch(Exception e) {
out.print( 'ERROR_RETRIEVING_MODEL  + e.getMessage() 
+ ');

}
}
out.println();
}

/**
 * Generates three spaces per level
 */
String tab(int level) {
char[] spaces = new char[level * 3];
Arrays.fill(spaces, ' ');
return new String(spaces);
}

}

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



Forms loading multiple times

2009-05-08 Thread Chris
I'm having a issue with forms loading multiple times.. This is really 
screwing up ChoiceRenderer.  Has anyone else experienced this?


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



Re: Forms loading multiple times

2009-05-08 Thread Igor Vaynberg
define loading

-igor

On Fri, May 8, 2009 at 9:34 AM, Chris ch...@carlsoncentral.com wrote:
 I'm having a issue with forms loading multiple times.. This is really
 screwing up ChoiceRenderer.  Has anyone else experienced 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: 60% waste

2009-05-08 Thread Martin Makundi
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

Well... printDoc and wicket
getDebugSettings().setOutputComponentPath(true); does pretty much the
same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 1.5

How can this help me? For example the following is HELL with wicket:

  Integer round = 1;
  String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
  TabbedPanel.TAB_PANEL_ID,
  AbstractInnerPanel.INNER_TABS,
  MyWizardPanel.WIZARD_FORM);
  String rowPath =
MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
  MyPeriodPanel.HISTORY_CONTAINER,
  MyPeriodPanel.HISTORY_TABLE,
  MyPeriodPanel.PERIODS,
  round.toString());

  // Add row
  tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
  MyWizardPanel.FANCY_PANEL_ID,
  MyPeriodPanel.HISTORY_CONTAINER,
  MyPeriodPanel.BUTTON_CONTAINER,
  MyPeriodPanel.NEW_BUTTON), onclick);

  // Fill entry
  FormTester formTester =
tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
  formTester.setValue(MarkupUtils.getComponentPath(rowPath,
  HistoryEditorTable.START_DATE), 26.1.2008);
  formTester.setValue(MarkupUtils.getComponentPath(rowPath,
  HistoryEditorTable.DAYS), 5);
  formTester.select(MarkupUtils.getComponentPath(rowPath,
  HistoryEditorTable.SETTING), 1);


**
Martin

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



Re: 60% waste

2009-05-08 Thread Igor Vaynberg
you should really use visitors for this kind of thing...something like
this may work very well for you

TestUtils.attachTestId(Component c, String id) {
  if (application.get().getconfigurationtype()!=production) {
  c.setmatadata(testkey, id);
  }
}

then in your code

Form form=new Form(..);
TestUtils.attachTestId(form, some_unique_form_id);

then in your tests

Page pageundertest=
Form form=TestUtils.findComponentByTestId(pageundertest, some_unique_form_id);

you have a potential problem of having collissions for components that
are inside repeaters, but you can set up test harnesses where you test
them in isolation.

-igor


On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 1.5

 How can this help me? For example the following is HELL with wicket:

      Integer round = 1;
      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
          TabbedPanel.TAB_PANEL_ID,
          AbstractInnerPanel.INNER_TABS,
          MyWizardPanel.WIZARD_FORM);
      String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.HISTORY_TABLE,
          MyPeriodPanel.PERIODS,
          round.toString());

      // Add row
      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
          MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.BUTTON_CONTAINER,
          MyPeriodPanel.NEW_BUTTON), onclick);

      // Fill entry
      FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.START_DATE), 26.1.2008);
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.DAYS), 5);
      formTester.select(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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: 60% waste

2009-05-08 Thread Igor Vaynberg
you can also create a test panel that contains just your form and test
that instead of creating the entire complex page just to test the
form. break your tests into small units and test in isolaton. your
test harness panel can have a getter that gives you direct access the
the form you are testing.

-igor

On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 1.5

 How can this help me? For example the following is HELL with wicket:

      Integer round = 1;
      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
          TabbedPanel.TAB_PANEL_ID,
          AbstractInnerPanel.INNER_TABS,
          MyWizardPanel.WIZARD_FORM);
      String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.HISTORY_TABLE,
          MyPeriodPanel.PERIODS,
          round.toString());

      // Add row
      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
          MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.BUTTON_CONTAINER,
          MyPeriodPanel.NEW_BUTTON), onclick);

      // Fill entry
      FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.START_DATE), 26.1.2008);
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.DAYS), 5);
      formTester.select(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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: 60% waste

2009-05-08 Thread Per Lundholm
Well, strings all over the place, if I get what you mean.

But I write the tests first and they define what the paths and ids
should be and Wicket is really quick about discovering when the
implementation doesn't follow spec (i.e. tests).

Doing a small step at a time takes you there faster.

Let's see there should be a label here, let's write a test for it and
run it. Oh, it failed. Guess I add a label to the code. Oh it throw an
exception, guess I add it to the markup as well. Green bar. Perhaps
another label...

if you do this in steps instead of doing a page at the time, you don't
need chasing typos so much since you immediatley discovers any
mistakes much more quickly.

/Per

On Fri, May 8, 2009 at 5:48 PM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 Hi!

 I use TDD: I spend 60% of my time type-checking and path-checking my
 wicketTests and components.

 I always have the wrong path and I must prinDocument and iterate to
 get it right

 Anybody have the same experience?

 How about introducing type-safety and path-safety/identity into
 component hierarchies?

 Can this be done?

 **
 Martin

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





-- 
FaceBush, min insamling i Mustaschkampen:
http://www.cancerfonden.se//sv/Mustaschkampen/Kampa/Insamlingar/?collection=243

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



Re: 60% waste

2009-05-08 Thread Martin Makundi
 you should really use visitors for this kind of thing...something like
 this may work very well for you

I know that with more work I can make ... more work.

What I am looking for is a solution that makes it possible to have
intellisense while coding and compile-time type checking. Visitors
etc. don't work (they do not save my time).

I know it must be possible... somehow. I just don't know what would be
the best way to make it happen.

**
Martin



 On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
 martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 
 1.5

 How can this help me? For example the following is HELL with wicket:

  Integer round = 1;
  String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
  TabbedPanel.TAB_PANEL_ID,
  AbstractInnerPanel.INNER_TABS,
  MyWizardPanel.WIZARD_FORM);
  String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
  MyPeriodPanel.HISTORY_CONTAINER,
  MyPeriodPanel.HISTORY_TABLE,
  MyPeriodPanel.PERIODS,
  round.toString());

  // Add row
  tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
  MyWizardPanel.FANCY_PANEL_ID,
  MyPeriodPanel.HISTORY_CONTAINER,
  MyPeriodPanel.BUTTON_CONTAINER,
  MyPeriodPanel.NEW_BUTTON), onclick);

  // Fill entry
  FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
  formTester.setValue(MarkupUtils.getComponentPath(rowPath,
  HistoryEditorTable.START_DATE), 26.1.2008);
  formTester.setValue(MarkupUtils.getComponentPath(rowPath,
  HistoryEditorTable.DAYS), 5);
  formTester.select(MarkupUtils.getComponentPath(rowPath,
  HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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



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



Re: 60% waste

2009-05-08 Thread James Carman
Use an IDE plugin?

On Fri, May 8, 2009 at 2:39 PM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 you should really use visitors for this kind of thing...something like
 this may work very well for you

 I know that with more work I can make ... more work.

 What I am looking for is a solution that makes it possible to have
 intellisense while coding and compile-time type checking. Visitors
 etc. don't work (they do not save my time).

 I know it must be possible... somehow. I just don't know what would be
 the best way to make it happen.

 **
 Martin



 On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
 martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 
 1.5

 How can this help me? For example the following is HELL with wicket:

      Integer round = 1;
      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
          TabbedPanel.TAB_PANEL_ID,
          AbstractInnerPanel.INNER_TABS,
          MyWizardPanel.WIZARD_FORM);
      String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.HISTORY_TABLE,
          MyPeriodPanel.PERIODS,
          round.toString());

      // Add row
      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
          MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.BUTTON_CONTAINER,
          MyPeriodPanel.NEW_BUTTON), onclick);

      // Fill entry
      FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.START_DATE), 26.1.2008);
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.DAYS), 5);
      formTester.select(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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



 -
 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: 60% waste

2009-05-08 Thread Martin Makundi
 But I write the tests first and they define what the paths and ids
 should be and Wicket is really quick about discovering when the
 implementation doesn't follow spec (i.e. tests).

I concentrate on coding.. sometimes I write the implementation,
sometimes the tests, whichever goes faster until it hangs and then I
switch over... but working with the tests is like working with some
prehistorical programming language without type and compile time
safety ... it just wastes a lot of my time, that's the problem.

Furthermore, I would like that when I refactor the component hierarcy,
the tests would follow. This means that maybe wicket component
hierarcy should be derived from package structure, maybe? Or something
more native to java.

**
Martin

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



Re: 60% waste

2009-05-08 Thread Martin Makundi
 Use an IDE plugin?

That's a hack, not a design.

**
Martin

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



Re: 60% waste

2009-05-08 Thread Igor Vaynberg
so what you are saying is that adding one line of code to mark the
component you want to test, and then being able to find that component
easily in your test - independent of its place in hierarchy and
without relying on strings - is more work?

-igor

On Fri, May 8, 2009 at 11:39 AM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 you should really use visitors for this kind of thing...something like
 this may work very well for you

 I know that with more work I can make ... more work.

 What I am looking for is a solution that makes it possible to have
 intellisense while coding and compile-time type checking. Visitors
 etc. don't work (they do not save my time).

 I know it must be possible... somehow. I just don't know what would be
 the best way to make it happen.

 **
 Martin



 On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
 martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 
 1.5

 How can this help me? For example the following is HELL with wicket:

      Integer round = 1;
      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
          TabbedPanel.TAB_PANEL_ID,
          AbstractInnerPanel.INNER_TABS,
          MyWizardPanel.WIZARD_FORM);
      String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.HISTORY_TABLE,
          MyPeriodPanel.PERIODS,
          round.toString());

      // Add row
      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
          MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.BUTTON_CONTAINER,
          MyPeriodPanel.NEW_BUTTON), onclick);

      // Fill entry
      FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.START_DATE), 26.1.2008);
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.DAYS), 5);
      formTester.select(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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



 -
 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: 60% waste

2009-05-08 Thread Igor Vaynberg
wicket component hierarchy is dynamic, so there is no predicting it at
compile time. this is one of the most powerful features of wicket.

-igor

On Fri, May 8, 2009 at 11:39 AM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 you should really use visitors for this kind of thing...something like
 this may work very well for you

 I know that with more work I can make ... more work.

 What I am looking for is a solution that makes it possible to have
 intellisense while coding and compile-time type checking. Visitors
 etc. don't work (they do not save my time).

 I know it must be possible... somehow. I just don't know what would be
 the best way to make it happen.

 **
 Martin



 On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
 martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 
 1.5

 How can this help me? For example the following is HELL with wicket:

      Integer round = 1;
      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
          TabbedPanel.TAB_PANEL_ID,
          AbstractInnerPanel.INNER_TABS,
          MyWizardPanel.WIZARD_FORM);
      String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.HISTORY_TABLE,
          MyPeriodPanel.PERIODS,
          round.toString());

      // Add row
      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
          MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.BUTTON_CONTAINER,
          MyPeriodPanel.NEW_BUTTON), onclick);

      // Fill entry
      FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.START_DATE), 26.1.2008);
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.DAYS), 5);
      formTester.select(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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



 -
 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: 60% waste

2009-05-08 Thread James Carman
What about introducing an xpath-ish like expression API that could
help you search for components within the hierarchy?

On Fri, May 8, 2009 at 3:07 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 wicket component hierarchy is dynamic, so there is no predicting it at
 compile time. this is one of the most powerful features of wicket.

 -igor

 On Fri, May 8, 2009 at 11:39 AM, Martin Makundi
 martin.maku...@koodaripalvelut.com wrote:
 you should really use visitors for this kind of thing...something like
 this may work very well for you

 I know that with more work I can make ... more work.

 What I am looking for is a solution that makes it possible to have
 intellisense while coding and compile-time type checking. Visitors
 etc. don't work (they do not save my time).

 I know it must be possible... somehow. I just don't know what would be
 the best way to make it happen.

 **
 Martin



 On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
 martin.maku...@koodaripalvelut.com wrote:
 I don't know if this is of any help, but I've written the attached
 utility class that, given a component, can print its containment
 structure, along with the eventual component classes and
 model values (toString-ed).

 Well... printDoc and wicket
 getDebugSettings().setOutputComponentPath(true); does pretty much the
 same thing.

 See jdave-wicket for better test support. Slated to come to you in Wicket 
 1.5

 How can this help me? For example the following is HELL with wicket:

      Integer round = 1;
      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
          TabbedPanel.TAB_PANEL_ID,
          AbstractInnerPanel.INNER_TABS,
          MyWizardPanel.WIZARD_FORM);
      String rowPath =
 MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.HISTORY_TABLE,
          MyPeriodPanel.PERIODS,
          round.toString());

      // Add row
      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
          MyWizardPanel.FANCY_PANEL_ID,
          MyPeriodPanel.HISTORY_CONTAINER,
          MyPeriodPanel.BUTTON_CONTAINER,
          MyPeriodPanel.NEW_BUTTON), onclick);

      // Fill entry
      FormTester formTester =
 tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.START_DATE), 26.1.2008);
      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.DAYS), 5);
      formTester.select(MarkupUtils.getComponentPath(rowPath,
          HistoryEditorTable.SETTING), 1);


 **
 Martin

 -
 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



 -
 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



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



Re: 60% waste

2009-05-08 Thread Christopher L Merrill

Martin Makundi wrote:

Use an IDE plugin?


That's a hack, not a design.


Wow...I'm new to this list, but I doubt you can expect much help with
that attitude.  I suggest you request a refund for your Wicket license
and support subscription and go find a tool that better fits your needs.

Oh, wait, Wicket is free and so is all the support you are receiving
here.   ;)


--
 -
Chris Merrill   |  Web Performance, Inc.
ch...@webperformance.com|  http://webperformance.com
919-433-1762|  919-845-7601

Website Load Testing and Stress Testing Software  Services
 -

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



Re: Stream/download files through portlet

2009-05-08 Thread Bruno Ledesma

Hello All!

Im facing problems trying to  Stream/download files through portlet. I also
used DynamicWebResource and a Resource link to serve the Resource Data. On a
simple Wicket application everything works fine, but when my war is deployed
as a portlet into a Liferay 5 instance, it doesnt work. 

The browser response is :  The requested resource
(/wick-portlet-0.0.1-SNAPSHOT/wick-portlet/) is not available.

Does anyone have some idea,or know any issue about this kind of feature?

thanks!

Bruno Ledesma


Rob Sonke wrote:
 
 Thijs and I debugged the code together this morning because when he read 
 this thread he was sure that both options (overriding setheaders and 
 onclick) should work. After some debugging we found a bug in Liferay 
 which could be easily fixed in our used version. The current (5.1.2) 
 version has a lot of changes around these properties, we will recheck 
 that once we're able to upgrade.
 
 Thanks for your help.
 
 Serkan Camurcuoglu wrote:
 In the PLT.12.1.1 section of jsr 286 it says:

 Response properties can be viewed as header values set for the portal
 application. If these header values are intended to be transmitted to the
 client they should be set before the response is committed. When setting
 headers in the render lifecycle phase portlets should set the header in
 the
 render headers part or simply override the GenericPortlet.doHeaders
 method
 (see PLT.11.1.1.4.3).

 I think you may try:

 PortletRequestContext ctx = (PortletRequestContext) RequestContext.get();
 PortletResponse presp = ctx.getPortletResponse();
 presp.addProperty(header, value);

 this is kind of a hack but it might work..




 Rob Sonke wrote:
   
 No, too bad. The headers aren't picked up.


 Serkan Camurcuoglu wrote:
 
 For the DynamicWebResource case, doesn't overriding setHeaders() in
 DynamicWebResource and adding your http header in this method work?

 By the way, which portlet container are you working with?




 Rob Sonke wrote:
   
   
 Hi,

 We're using wicket for our portlets now for almost 3/4 year and it's 
 great. We're following/try to help with the full implementation of jsr 
 286 in wicket too (Thijs and me, see other threads). But I'm having a 
 problem now with offering files through a portlet. There are actually 
 two options, use the resource phase of jsr286 or use a separate
 download 
 servlet. First option rocks, second option not (if option 1 won't
 work, 
 I'll have to deal with it but I prefer not).

 So I'm trying to serve a file through the portlet based on a wicket 
 link. A normal link would end up in a actionResponse which will not 
 allow you to touch the resourcestream (returning null as the portlet 
 specs describe). An ajax link (which uses the resource phase) will end 
 up with a lot of binary code in the ajax xml output which will, of 
 course, not work.

 I tried also adding a DynamicWebResource to a wicket ResourceLink,
 which 
 works actually pretty good except that he's not communicating the 
 filename to the brower by setting a header. I tried adding a header to 
 the ResourceResponse but that one was not passed to the client too 
 (maybe I did that wrong).

 Could anyone point me in the right direction or could tell me what I'm 
 doing wrong over here?

 Regards,
 Rob

 -
 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



 

   
 
 

-- 
View this message in context: 
http://www.nabble.com/Stream-download-files-through-portlet-tp19980617p23452007.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: 60% waste

2009-05-08 Thread Andrea Aime

Martin Makundi ha scritto:

I don't know if this is of any help, but I've written the attached
utility class that, given a component, can print its containment
structure, along with the eventual component classes and
model values (toString-ed).


Well... printDoc and wicket
getDebugSettings().setOutputComponentPath(true); does pretty much the
same thing.


Interesting. I googled for printDoc Wicket but did not find anything.
Where is that utility?

Cheers
Andrea

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



Re: Stream/download files through portlet

2009-05-08 Thread Bruno Ledesma
Solved.

Its a Liferay issue.
http://issues.liferay.com/browse/LPS-1911

I was using portlet names and  filter-mapping with a - char.

 I have to use the same string value for the portlet name and the
filter-mapping stuff... without the - char, cause liferay (i dont have
idea why) removes this char, causing the problem.

sorry for the inconvenient question...

Bruno

2009/5/8 Bruno Ledesma led.br...@gmail.com


 Hello All!

 Im facing problems trying to  Stream/download files through portlet. I also
 used DynamicWebResource and a Resource link to serve the Resource Data. On
 a
 simple Wicket application everything works fine, but when my war is
 deployed
 as a portlet into a Liferay 5 instance, it doesnt work.

 The browser response is :  The requested resource
 (/wick-portlet-0.0.1-SNAPSHOT/wick-portlet/) is not available.

 Does anyone have some idea,or know any issue about this kind of feature?

 thanks!

 Bruno Ledesma


 Rob Sonke wrote:
 
  Thijs and I debugged the code together this morning because when he read
  this thread he was sure that both options (overriding setheaders and
  onclick) should work. After some debugging we found a bug in Liferay
  which could be easily fixed in our used version. The current (5.1.2)
  version has a lot of changes around these properties, we will recheck
  that once we're able to upgrade.
 
  Thanks for your help.
 
  Serkan Camurcuoglu wrote:
  In the PLT.12.1.1 section of jsr 286 it says:
 
  Response properties can be viewed as header values set for the portal
  application. If these header values are intended to be transmitted to
 the
  client they should be set before the response is committed. When setting
  headers in the render lifecycle phase portlets should set the header in
  the
  render headers part or simply override the GenericPortlet.doHeaders
  method
  (see PLT.11.1.1.4.3).
 
  I think you may try:
 
  PortletRequestContext ctx = (PortletRequestContext)
 RequestContext.get();
  PortletResponse presp = ctx.getPortletResponse();
  presp.addProperty(header, value);
 
  this is kind of a hack but it might work..
 
 
 
 
  Rob Sonke wrote:
 
  No, too bad. The headers aren't picked up.
 
 
  Serkan Camurcuoglu wrote:
 
  For the DynamicWebResource case, doesn't overriding setHeaders() in
  DynamicWebResource and adding your http header in this method work?
 
  By the way, which portlet container are you working with?
 
 
 
 
  Rob Sonke wrote:
 
 
  Hi,
 
  We're using wicket for our portlets now for almost 3/4 year and it's
  great. We're following/try to help with the full implementation of
 jsr
  286 in wicket too (Thijs and me, see other threads). But I'm having a
  problem now with offering files through a portlet. There are actually
  two options, use the resource phase of jsr286 or use a separate
  download
  servlet. First option rocks, second option not (if option 1 won't
  work,
  I'll have to deal with it but I prefer not).
 
  So I'm trying to serve a file through the portlet based on a wicket
  link. A normal link would end up in a actionResponse which will not
  allow you to touch the resourcestream (returning null as the portlet
  specs describe). An ajax link (which uses the resource phase) will
 end
  up with a lot of binary code in the ajax xml output which will, of
  course, not work.
 
  I tried also adding a DynamicWebResource to a wicket ResourceLink,
  which
  works actually pretty good except that he's not communicating the
  filename to the brower by setting a header. I tried adding a header
 to
  the ResourceResponse but that one was not passed to the client too
  (maybe I did that wrong).
 
  Could anyone point me in the right direction or could tell me what
 I'm
  doing wrong over here?
 
  Regards,
  Rob
 
  -
  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
 
 
 
 
 
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Stream-download-files-through-portlet-tp19980617p23452007.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




DropDownChoice ID's

2009-05-08 Thread Chris

List test = Arrays.asList(new String[] { A, B, C });
add(new DropDownChoice(test, test));

How can I make the Id's match the Values?  There coming through as 
1,2,3.  I've tried custom ChoiceRenderer, but seem to be missing something.


Any help is appreciated.

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



Re: Forms loading multiple times

2009-05-08 Thread Oblivian

I mean the DAO that populates my model, runs 2 times.


Oblivian wrote:
 
 I'm having a issue with forms loading multiple times.. This is really 
 screwing up ChoiceRenderer.  Has anyone else experienced this?
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Forms-loading-multiple-times-tp23449346p23453892.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: Forms loading multiple times

2009-05-08 Thread Igor Vaynberg
if you use a detachable model connected to your dao then it will call
the dao every render.

-igor

On Fri, May 8, 2009 at 2:21 PM, Oblivian ch...@carlsoncentral.com wrote:

 I mean the DAO that populates my model, runs 2 times.


 Oblivian wrote:

 I'm having a issue with forms loading multiple times.. This is really
 screwing up ChoiceRenderer.  Has anyone else experienced this?

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




 --
 View this message in context: 
 http://www.nabble.com/Forms-loading-multiple-times-tp23449346p23453892.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



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



Re: DropDownChoice ID's

2009-05-08 Thread Igor Vaynberg
new ichoicerendererstring {
  object getid(string object, int index) { return object; }
  string getdisplayvalue(string object) { return object; }
}

-igor

On Fri, May 8, 2009 at 2:19 PM, Chris ch...@carlsoncentral.com wrote:
 List test = Arrays.asList(new String[] { A, B, C });
 add(new DropDownChoice(test, test));

 How can I make the Id's match the Values?  There coming through as 1,2,3.
  I've tried custom ChoiceRenderer, but seem to be missing something.

 Any help is appreciated.

 -
 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: DropDownChoice ID's

2009-05-08 Thread Oblivian

Think I figured it out by doing something like this.  Is this the right way?

public class StringChoiceRender implements IChoiceRenderer {

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

}


Oblivian wrote:
 
  List test = Arrays.asList(new String[] { A, B, C });
  add(new DropDownChoice(test, test));
 
 How can I make the Id's match the Values?  There coming through as 
 1,2,3.  I've tried custom ChoiceRenderer, but seem to be missing
 something.
 
 Any help is appreciated.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23454055.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



inmethod grid generics patch

2009-05-08 Thread Brill Pappin

according to this post;

http://tinyurl.com/qlghyf

the inmethod grid it he wicketstuff modules was to get generics.

I'm finding the missing generics a real pain in the behind but I also  
have a recent checkout of the 1.4-SNAPSHOT of wicketstuff, and it does  
not yet have generics.


Does anyone know if this component has been abandoned or not?
If I have to I'll go an add the generics myself, but if there is a  
copy out there that already has them I'd rather use that version.


- Brill Pappin

smime.p7s
Description: S/MIME cryptographic signature


Re: inmethod grid generics patch

2009-05-08 Thread Matej Knopp
Hi,

it's not abandoned. There's a project created for it in wicketstuff
jira that can be used to submit patches.

-Matej

On Fri, May 8, 2009 at 11:49 PM, Brill Pappin br...@pappin.ca wrote:
 according to this post;

 http://tinyurl.com/qlghyf

 the inmethod grid it he wicketstuff modules was to get generics.

 I'm finding the missing generics a real pain in the behind but I also have a
 recent checkout of the 1.4-SNAPSHOT of wicketstuff, and it does not yet have
 generics.

 Does anyone know if this component has been abandoned or not?
 If I have to I'll go an add the generics myself, but if there is a copy out
 there that already has them I'd rather use that version.

 - Brill Pappin

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



Re: inmethod grid generics patch

2009-05-08 Thread Matej Knopp
Found the patch, will assign it to jira issue. And possibly apply after review.

-Matej

On Fri, May 8, 2009 at 11:54 PM, Matej Knopp matej.kn...@gmail.com wrote:
 Hi,

 it's not abandoned. There's a project created for it in wicketstuff
 jira that can be used to submit patches.

 -Matej

 On Fri, May 8, 2009 at 11:49 PM, Brill Pappin br...@pappin.ca wrote:
 according to this post;

 http://tinyurl.com/qlghyf

 the inmethod grid it he wicketstuff modules was to get generics.

 I'm finding the missing generics a real pain in the behind but I also have a
 recent checkout of the 1.4-SNAPSHOT of wicketstuff, and it does not yet have
 generics.

 Does anyone know if this component has been abandoned or not?
 If I have to I'll go an add the generics myself, but if there is a copy out
 there that already has them I'd rather use that version.

 - Brill Pappin


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



Re: DropDownChoice ID's

2009-05-08 Thread Oblivian

Thanks.


Oblivian wrote:
 
  List test = Arrays.asList(new String[] { A, B, C });
  add(new DropDownChoice(test, test));
 
 How can I make the Id's match the Values?  There coming through as 
 1,2,3.  I've tried custom ChoiceRenderer, but seem to be missing
 something.
 
 Any help is appreciated.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23454080.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: inmethod grid generics patch

2009-05-08 Thread Brill Pappin

That would be great!

If you need an area to focus on, it's the generics that type things  
like getSelectedItems() etc. and some of the other common overrides.


- Brill Pappin


On 8-May-09, at 5:57 PM, Matej Knopp wrote:

Found the patch, will assign it to jira issue. And possibly apply  
after review.


-Matej

On Fri, May 8, 2009 at 11:54 PM, Matej Knopp matej.kn...@gmail.com  
wrote:

Hi,

it's not abandoned. There's a project created for it in wicketstuff
jira that can be used to submit patches.

-Matej

On Fri, May 8, 2009 at 11:49 PM, Brill Pappin br...@pappin.ca  
wrote:

according to this post;

http://tinyurl.com/qlghyf

the inmethod grid it he wicketstuff modules was to get generics.

I'm finding the missing generics a real pain in the behind but I  
also have a
recent checkout of the 1.4-SNAPSHOT of wicketstuff, and it does  
not yet have

generics.

Does anyone know if this component has been abandoned or not?
If I have to I'll go an add the generics myself, but if there is a  
copy out

there that already has them I'd rather use that version.

- Brill Pappin




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





smime.p7s
Description: S/MIME cryptographic signature


Re: 60% waste

2009-05-08 Thread Martin Makundi
 Interesting. I googled for printDoc Wicket but did not find anything.
 Where is that utility?

  public void printDocument() {
System.out.println(tester.getServletResponse().getDocument());
  }

**
Martin

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



Re: 60% waste

2009-05-08 Thread Martin Makundi
 wicket component hierarchy is dynamic, so there is no predicting it at
 compile time. this is one of the most powerful features of wicket.

Yes but each component is always fixed relative to its parent. The
html markup fixes the hierarcy, so something might be devised here.

 What about introducing an xpath-ish like expression API that could
 help you search for components within the hierarchy?

I am not familiar with this but sounds good, anybody have a suitable
example for this?

**
Martin



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