Re: [Wicket-user] FieldLabel component

2005-08-20 Thread Joshua Lim
On 7/30/05, Gert Jan Verhoog [EMAIL PROTECTED] wrote:
 On Jul 30, 2005, at 04:44, Igor Vaynberg wrote:
 
  This will create a field label that will turn red when the linked form
  component has an error.
 
  Another good use is to prepand an asterisk to the fieldlabel's
  label if the
  linked form component has a requiredvalidator added.
 
 I did more or less the same thing the other day. My FieldLabel class
 does two things: It checks the list of validators attached to the
 form component (if it's a FormComponent). If the list contains a
 RequiredValidator, the value required is added to the label's class
 attribute. If the component has feedback messages, I add error to
 the label's class attribute.

Hi Gert, I am interested in your example, are you able to send me some
examples? thanks

josh


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


RE: [Wicket-user] FieldLabel component

2005-07-30 Thread Igor Vaynberg
Here is a less intrusive patch.

-Igor
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf 
 Of Jonathan 
  Locke
  Sent: Friday, July 29, 2005 10:03 PM
  To: wicket-user@lists.sourceforge.net
  Subject: Re: [Wicket-user] FieldLabel component
  
  
  well, i don't know what's happened to the feedback interface stuff 
  recently, but it was originally designed to be general enough to 
  support what you're
  trying to do.   seems like what you're writing is more or less a 
  FormComponentFeedbackLabel.  and the link is simply implementing 
  IFeedback (or it used to be... i'm not sure what's 
 changed... it looks 
  unfamiliar now).
  the form code then finds the associated feedback elements for each 
  form component.
  
  Igor Vaynberg wrote:
  
  I've seen the error border, it doesn't do what I want - in 
 our app a 
  red asterisk indicates a required field and field labels
  with errors turn red.
  What I am looking for is a way to link the label to the
  component not
  the other way around. My primary interest was the validator
  stuff, the
  decoration of the label was a bonus.
  
  -Igor
  
  

  
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf
  Of Jonathan
  Locke
  Sent: Friday, July 29, 2005 8:14 PM
  To: wicket-user@lists.sourceforge.net
  Subject: Re: [Wicket-user] FieldLabel component
  
  
  if you just want to show an error indicator like a red
  asterisk, see
  FormComponentFeedbackBorder.
  i personally don't like the idea of changing field label
  contents on
  users.  so instead, i've emphasized FeedbackPanel and IFeedback.
  however, you should be able to implement what you're 
 talking about 
  though by implementing IFeedback on a subclass of Label.
  
  Igor Vaynberg wrote:
  
  
  
  Hi Guys,
  
  Ive been working on forms a lot lately, and what ive been

  
  missing from
  
  
  tapestry is a fieldlabel component. Basically a fieldlabel

  
  is a label
  
  
  that is linked to a form component.
  
  This allows to do cool things like:
  
  1) FieldLabel can change its apperance based on the form 
 component
  
  TextField tf=new RequiredTextField(...) FieldLabel lb=new 
  FieldLabel(label1,First Name, tf) {
   public void initialize() {
   add(new AttributeModifier(style, true, new
  Model(color:red;)) {
   public boolean isEnabled()
   {
   return !getFieldComponent().isValid();
   }
   });
   }
  };
  
  This will create a field label that will turn red when the

  
  linked form
  
  
  component has an error.
  
  Another good use is to prepand an asterisk to the

  
  fieldlabel's label if
  
  
  the linked form component has a requiredvalidator added.
  
  2) FieldLabel's label can participate in validator messages
  
  With this patch it is possible to create generic error

  
  messages of form :
  
  
  '${label}' is required or '${label}' contains an invalid

  
  email address
  
  
  I am looking for feedback and ideas on how to make this

  
  better before I
  
  
  submit this as a patch.
  
  Thank you!
  Igor
   
  
  -

  
  --
  
  
  -
  
  Index: wicket/markup/html/form/FormComponent.java
  
 ===
  RCS file: 
  /cvsroot/wicket/wicket/src/java/wicket/markup/html/form/FormC

  
  omponent.j
  
  
  ava,v
  retrieving revision 1.43
  diff -u -r1.43 FormComponent.java
  --- wicket/markup/html/form/FormComponent.java   28 Jul 

  
  2005 11:56:51 -   1.43
  
  
  +++ wicket/markup/html/form/FormComponent.java   30 Jul 

  
  2005 02:32:19 -
  
  
  @@ -30,6 +30,7 @@
  import wicket.model.IModel;
  import wicket.util.lang.Classes;
  import wicket.util.string.StringList;
  +import wicket.version.undo.Change;
  
  /**
   * An html form component knows how to validate itself. 
 Validators 
  that @@ -71,6 +72,9 @@
   /** The validator or validator list for this component. */
   private IValidator validator = IValidator.NULL;
  
  +/** The field label for this component */
  +private FieldLabel fieldLabel;
  +
   /**
* Typesafe interface to code that is called when

  
  visiting a form component
  
  
*
  @@ -575,4 +579,24 @@
   {
   validator.validate(this);
   }
  +
  +protected FormComponent 
 setFieldLabel(FieldLabel label) {
  +if (fieldLabel!=null) {
  +
  +addStateChange(new Change() {
  +private final FieldLabel
  +oldFieldLabel=FormComponent.this.fieldLabel;
  +
  +public void undo

Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Jonathan Locke


efficiency is the least of our worries here.  what's more, the search 
for feedback interfaces
on a form validate (which doesn't happen that often) is already in place 
in order to support the
existing extension mechanism.  while your suggested change would fix 
your particular problem,
wicket needs to take a more general view.  it should be possible to 
implement absolutely any
kind of feedback mechanism for forms.  not just label-oriented 
feedback.  i think we should
stick with what we've got since it's completely general and enhance it 
only if we have to in order

to implement a feedback label component.  make sense?

i agree that you shouldn't have to cast the IFeedback to a Component.  
in the past, this was
not necessary... i no longer understand the code here though...  what is 
this refactor, eelco?
and what is a collectingComponent ?? 

in the past, any component could implement IFeedback and act as a sink 
for feedback information:


public interface IFeedback
{
   /**
* Called to add feedback messages from a component. If the 
component is a

* container, messages will be added for all children of the container.
*
* @param component
*The component with associated feedback messages
* @param recurse
*True if feedback messages should be added from 
children of the

*given component
*/
   public void addFeedbackMessages(Component component, boolean recurse);
}

this is a very powerful way to wire things up and i don't understand why 
this was changed.


Igor Vaynberg wrote:


I can kind of see what you are saying. The abstract validator would have to
search the page and find the Ifeedback for the formcomponent in error. But
what if you have two ifeedbacks for a component - the feedback panel and the
label? The search is also inefficient for something simple like this, I
don't think a link in a formcomponent to a labelcomponent is that big a
deal. In abstract validator you would also have to cast Ifeedback to a
Component in order to get the model, this isnt very safe, it would be nice
to have Icomponent and have Ifeedback extend Icomponent.

Igor


 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Jonathan Locke

Sent: Friday, July 29, 2005 10:03 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


well, i don't know what's happened to the feedback interface 
stuff recently, but it was originally designed to be general 
enough to support what you're
trying to do.   seems like what you're writing is more or less a 
FormComponentFeedbackLabel.  and the link is simply 
implementing IFeedback (or it used to be... i'm not sure 
what's changed... it looks unfamiliar now).
the form code then finds the associated feedback elements for 
each form component.


Igor Vaynberg wrote:

   

I've seen the error border, it doesn't do what I want - in our app a 
red asterisk indicates a required field and field labels 
 


with errors turn red.
   

What I am looking for is a way to link the label to the 
 

component not 
   

the other way around. My primary interest was the validator 
 

stuff, the 
   


decoration of the label was a bonus.

-Igor




 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf 
   

Of Jonathan 
   


Locke
Sent: Friday, July 29, 2005 8:14 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


if you just want to show an error indicator like a red 
   

asterisk, see 
   


FormComponentFeedbackBorder.
i personally don't like the idea of changing field label 
   

contents on 
   


users.  so instead, i've emphasized FeedbackPanel and IFeedback.
however, you should be able to implement what you're talking about 
though by implementing IFeedback on a subclass of Label.


Igor Vaynberg wrote:

  

   


Hi Guys,

Ive been working on forms a lot lately, and what ive been


 


missing from
  

   


tapestry is a fieldlabel component. Basically a fieldlabel


 


is a label
  

   


that is linked to a form component.

This allows to do cool things like:

1) FieldLabel can change its apperance based on the form component

TextField tf=new RequiredTextField(...) FieldLabel lb=new 
FieldLabel(label1,First Name, tf) {

public void initialize() {
add(new AttributeModifier(style, true, new
Model(color:red;)) {
public boolean isEnabled()
{
return !getFieldComponent().isValid();
}
});
}
};

This will create a field label that will turn red when the


 


linked form
  

   


component has an error.

Another good use is to prepand an asterisk to the


 


fieldlabel's label if
  

   


the linked form component has

Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Jonathan Locke


ok, i see... it looks like this is all changed now.  if i understand, 
the collectingComponent is
really a formComponent that the feedback is optionally attached to.  i 
think this is actually
slightly more general than the old code, which only searched parents.  
but the refactor doesn't
seem like it's done because the whole idea of a feedback border is 
kindof meaningless
since the containment hierarchy isn't always being used to wire things up. 

it seems like there ought to be (at least) two classes here... 
FormComponentFeedbackBorder,
which visits its children looking for errors and 
FormComponentErrorIndicator, which changes
its visibility based on any errors set on a particular form component 
(which is what collectingComponent
seems to be). 

given this refactor, i'm unsure what use IFeedback is at all... seems 
like each feedback implementation
can just do its own search for errors and we could remove the IFeedback 
from Form constructor... 




Jonathan Locke wrote:



efficiency is the least of our worries here.  what's more, the search 
for feedback interfaces
on a form validate (which doesn't happen that often) is already in 
place in order to support the
existing extension mechanism.  while your suggested change would fix 
your particular problem,
wicket needs to take a more general view.  it should be possible to 
implement absolutely any
kind of feedback mechanism for forms.  not just label-oriented 
feedback.  i think we should
stick with what we've got since it's completely general and enhance it 
only if we have to in order

to implement a feedback label component.  make sense?

i agree that you shouldn't have to cast the IFeedback to a Component.  
in the past, this was
not necessary... i no longer understand the code here though...  what 
is this refactor, eelco?

and what is a collectingComponent ??
in the past, any component could implement IFeedback and act as a 
sink for feedback information:


public interface IFeedback
{
   /**
* Called to add feedback messages from a component. If the 
component is a
* container, messages will be added for all children of the 
container.

*
* @param component
*The component with associated feedback messages
* @param recurse
*True if feedback messages should be added from 
children of the

*given component
*/
   public void addFeedbackMessages(Component component, boolean recurse);
}

this is a very powerful way to wire things up and i don't understand 
why this was changed.


Igor Vaynberg wrote:

I can kind of see what you are saying. The abstract validator would 
have to
search the page and find the Ifeedback for the formcomponent in 
error. But
what if you have two ifeedbacks for a component - the feedback panel 
and the

label? The search is also inefficient for something simple like this, I
don't think a link in a formcomponent to a labelcomponent is that big a
deal. In abstract validator you would also have to cast Ifeedback to a
Component in order to get the model, this isnt very safe, it would be 
nice

to have Icomponent and have Ifeedback extend Icomponent.

Igor


 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Jonathan Locke

Sent: Friday, July 29, 2005 10:03 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


well, i don't know what's happened to the feedback interface stuff 
recently, but it was originally designed to be general enough to 
support what you're
trying to do.   seems like what you're writing is more or less a 
FormComponentFeedbackLabel.  and the link is simply implementing 
IFeedback (or it used to be... i'm not sure what's changed... it 
looks unfamiliar now).
the form code then finds the associated feedback elements for each 
form component.


Igor Vaynberg wrote:

  

I've seen the error border, it doesn't do what I want - in our app 
a red asterisk indicates a required field and field labels 


with errors turn red.
  

What I am looking for is a way to link the label to the 


component not   

the other way around. My primary interest was the validator 


stuff, the   


decoration of the label was a bonus.

-Igor







-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf   


Of Jonathan   


Locke
Sent: Friday, July 29, 2005 8:14 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


if you just want to show an error indicator like a red   


asterisk, see   


FormComponentFeedbackBorder.
i personally don't like the idea of changing field label   


contents on   


users.  so instead, i've emphasized FeedbackPanel and IFeedback.
however, you should be able to implement what you're talking about 
though by implementing IFeedback on a subclass of Label.


Igor Vaynberg wrote:

 
  


Hi Guys,

Ive been working on forms a lot lately

Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Eelco Hillenius

Jonathan Locke wrote:



efficiency is the least of our worries here.  what's more, the search 
for feedback interfaces
on a form validate (which doesn't happen that often) is already in 
place in order to support the
existing extension mechanism.  while your suggested change would fix 
your particular problem,
wicket needs to take a more general view.  it should be possible to 
implement absolutely any
kind of feedback mechanism for forms.  not just label-oriented 
feedback.  i think we should
stick with what we've got since it's completely general and enhance it 
only if we have to in order

to implement a feedback label component.  make sense?

i agree that you shouldn't have to cast the IFeedback to a Component.  
in the past, this was
not necessary... i no longer understand the code here though...  what 
is this refactor, eelco?

and what is a collectingComponent ??



Who says IFeedback needs to be cast to a component? I don't think so?

in the past, any component could implement IFeedback and act as a 
sink for feedback information:


public interface IFeedback
{
   /**
* Called to add feedback messages from a component. If the 
component is a
* container, messages will be added for all children of the 
container.

*
* @param component
*The component with associated feedback messages
* @param recurse
*True if feedback messages should be added from 
children of the

*given component
*/
   public void addFeedbackMessages(Component component, boolean recurse);
}

this is a very powerful way to wire things up and i don't understand 
why this was changed.


It was changed because it didn't work. The way that code was set up had 
the effect of tons of (FeedbackPanel specific) calls from the outside. 
Bugs kept popping up, and the code was getting spaghetti like.


It's hard to get the exact details back now - it was changed quite a 
while ago - but the main rationales behind the changes were:
* get back to a point were feedback aware components are not so much 
dependent of other classes/ the request cycle processing;
* it was too generic in the sense that it those components trapped 
either one message or all messages of the whole page;
* it was too specific in the sense that it wasn't possible to e.g. have 
a group of related components (like a few radiofields and one textfield 
that work together), and trap messages for just that component.


I introducted IFeedbackBoundary to have a 'stopper' in the hierarchy the 
*optionally* says (as you can decide yourself whether you actually 
*want* to use IFeedbackBoundary), here's where you stop.


Not only makes that possible for creating feedback 'groups' 
specifically, but also works much better out of the box. Page and Form 
are the boundaries now, which means that if you want to have a seperate 
trap for non-form related messages, and one just for the form, you can 
do that now.


The collecting component lets you override the normal feedback 
boundaries so that you can decide to use that component as the boundary, 
or to trap messages for just that component.


It should be our goal to let people easily create custom feedback 
components, not to just have the existing feedback panel and form 
component feedback border (which I allways found too specific btw) work 
in the way we think it is handy for people. I think we need the feedback 
boundary and collection component concepts to ensure flexibility. And I 
think such components should *not* be dependent of our request 
processing cycle so much.


Eelco



Igor Vaynberg wrote:

I can kind of see what you are saying. The abstract validator would 
have to
search the page and find the Ifeedback for the formcomponent in 
error. But
what if you have two ifeedbacks for a component - the feedback panel 
and the

label? The search is also inefficient for something simple like this, I
don't think a link in a formcomponent to a labelcomponent is that big a
deal. In abstract validator you would also have to cast Ifeedback to a
Component in order to get the model, this isnt very safe, it would be 
nice

to have Icomponent and have Ifeedback extend Icomponent.

Igor


 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Jonathan Locke

Sent: Friday, July 29, 2005 10:03 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


well, i don't know what's happened to the feedback interface stuff 
recently, but it was originally designed to be general enough to 
support what you're
trying to do.   seems like what you're writing is more or less a 
FormComponentFeedbackLabel.  and the link is simply implementing 
IFeedback (or it used to be... i'm not sure what's changed... it 
looks unfamiliar now).
the form code then finds the associated feedback elements for each 
form component.


Igor Vaynberg wrote:

  

I've seen the error border, it doesn't do what I want - in our app

Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Jonathan Locke


It was changed because it didn't work. The way that code was set up 
had the effect of tons of (FeedbackPanel specific) calls from the 
outside. Bugs kept popping up, and the code was getting spaghetti like.


ah, well... there you go  ;-)

It's hard to get the exact details back now - it was changed quite a 
while ago - but the main rationales behind the changes were:
* get back to a point were feedback aware components are not so much 
dependent of other classes/ the request cycle processing;
* it was too generic in the sense that it those components trapped 
either one message or all messages of the whole page;
* it was too specific in the sense that it wasn't possible to e.g. 
have a group of related components (like a few radiofields and one 
textfield that work together), and trap messages for just that component.


I introducted IFeedbackBoundary to have a 'stopper' in the hierarchy 
the *optionally* says (as you can decide yourself whether you actually 
*want* to use IFeedbackBoundary), here's where you stop.


Not only makes that possible for creating feedback 'groups' 
specifically, but also works much better out of the box. Page and Form 
are the boundaries now, which means that if you want to have a 
seperate trap for non-form related messages, and one just for the 
form, you can do that now.


The collecting component lets you override the normal feedback 
boundaries so that you can decide to use that component as the 
boundary, or to trap messages for just that component.


yeah, i get it now... but it's too complex now.  it's a kind of wierd 
hybrid between the old push model and your new pull model.  i think we 
need to refactor again and make it all a really simple, elegant pull 
model...




It should be our goal to let people easily create custom feedback 
components, not to just have the existing feedback panel and form 
component feedback border (which I allways found too specific btw) 
work in the way we think it is handy for people. I think we need the 
feedback boundary and collection component concepts to ensure 
flexibility. And I think such components should *not* be dependent of 
our request processing cycle so much.


this much we ALL agree on.  have a look at the proposal i just sent 
out.  i think we can make this whole thing a lot simpler somehow...




Eelco



Igor Vaynberg wrote:

I can kind of see what you are saying. The abstract validator would 
have to
search the page and find the Ifeedback for the formcomponent in 
error. But
what if you have two ifeedbacks for a component - the feedback panel 
and the

label? The search is also inefficient for something simple like this, I
don't think a link in a formcomponent to a labelcomponent is that big a
deal. In abstract validator you would also have to cast Ifeedback to a
Component in order to get the model, this isnt very safe, it would 
be nice

to have Icomponent and have Ifeedback extend Icomponent.

Igor


 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Jonathan Locke

Sent: Friday, July 29, 2005 10:03 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


well, i don't know what's happened to the feedback interface stuff 
recently, but it was originally designed to be general enough to 
support what you're
trying to do.   seems like what you're writing is more or less a 
FormComponentFeedbackLabel.  and the link is simply implementing 
IFeedback (or it used to be... i'm not sure what's changed... it 
looks unfamiliar now).
the form code then finds the associated feedback elements for each 
form component.


Igor Vaynberg wrote:

 

I've seen the error border, it doesn't do what I want - in our app 
a red asterisk indicates a required field and field labels 



with errors turn red.
 

What I am looking for is a way to link the label to the 



component not  

the other way around. My primary interest was the validator 



stuff, the  


decoration of the label was a bonus.

-Igor




   


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf   



Of Jonathan  


Locke
Sent: Friday, July 29, 2005 8:14 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


if you just want to show an error indicator like a red   



asterisk, see  


FormComponentFeedbackBorder.
i personally don't like the idea of changing field label   



contents on  


users.  so instead, i've emphasized FeedbackPanel and IFeedback.
however, you should be able to implement what you're talking 
about though by implementing IFeedback on a subclass of Label.


Igor Vaynberg wrote:

 
 


Hi Guys,

Ive been working on forms a lot lately, and what ive been
   



missing from
 
 


tapestry is a fieldlabel component. Basically a fieldlabel
   



is a label
 
 


that is linked to a form component.

This allows to do cool things like:

1

Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Gert Jan Verhoog

On Jul 30, 2005, at 04:44, Igor Vaynberg wrote:


This will create a field label that will turn red when the linked form
component has an error.

Another good use is to prepand an asterisk to the fieldlabel's  
label if the

linked form component has a requiredvalidator added.


I did more or less the same thing the other day. My FieldLabel class  
does two things: It checks the list of validators attached to the  
form component (if it's a FormComponent). If the list contains a  
RequiredValidator, the value required is added to the label's class  
attribute. If the component has feedback messages, I add error to  
the label's class attribute.


I like to keep my html as simple and semantically sound as possible  
and do all styling in CSS. The actual content of the label is never  
changed, just the CSS. The relevant CSS could look like this:


label:after   { content: :; }
label.required:before { content: *; }
label.error   { font-style: italic;  color: red;}

This will render a : after every field label. When the label's  
class is required, it renders an asterisk in front of the label.  
Obviously a class of error renders the label in red and italic, and  
the neat thing is that you can apply multiple CSS classes by using a  
space separated list of names in your class attribute. So label  
class=error required.../label will render in red and italic,  
with a '*' in front and a ':' at the end.


Sometimes, a field label is used for multiple fields (credit card  
number and 3-digit security code, for example, or a 4x4 digit prepaid  
voucher number field). That's why I added the possiblity to pass an  
array of components to FieldLabel - the label's appearance will  
change based on any field in the array.


cheers,
Gert Jan


---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477alloc_id=16492op=click
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Jonathan Locke


good idea... if i had the time for that!  i really think that 
updateFeedback() is about as general as you can get.  there is no 
limitation on what components a feedback component can watch or how and 
there is no limitation on what the feedback component can do in response 
to any kind of error condition (or any other condition you can dream 
up).  the only contract is that the framework will tell your feedback 
component /when/ to update its look.  i can't readily see any way to 
make a more general design...


Eelco Hillenius wrote:



yeah, i get it now... but it's too complex now.  it's a kind of wierd 
hybrid between the old push model and your new pull model.  i think 
we need to refactor again and make it all a really simple, elegant 
pull model...




It should be our goal to let people easily create custom feedback 
components, not to just have the existing feedback panel and form 
component feedback border (which I allways found too specific btw) 
work in the way we think it is handy for people. I think we need the 
feedback boundary and collection component concepts to ensure 
flexibility. And I think such components should *not* be dependent 
of our request processing cycle so much.




this much we ALL agree on.  have a look at the proposal i just sent 
out.  i think we can make this whole thing a lot simpler somehow...




Sure, making it simpler is allways good.

Why don't we make a special example app in wicket-examples on the 
different feedback scenario's we can think of? We'll have our 
playground then, we document the different usages by it, and actual 
cases make us think better about what we need.


Eelco


---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477alloc_id=16492op=click
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477alloc_id=16492op=click
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] FieldLabel component

2005-07-30 Thread Jonathan Locke


wow.  that's really cool.

Gert Jan Verhoog wrote:


On Jul 30, 2005, at 04:44, Igor Vaynberg wrote:


This will create a field label that will turn red when the linked form
component has an error.

Another good use is to prepand an asterisk to the fieldlabel's  label 
if the

linked form component has a requiredvalidator added.



I did more or less the same thing the other day. My FieldLabel class  
does two things: It checks the list of validators attached to the  
form component (if it's a FormComponent). If the list contains a  
RequiredValidator, the value required is added to the label's class  
attribute. If the component has feedback messages, I add error to  
the label's class attribute.


I like to keep my html as simple and semantically sound as possible  
and do all styling in CSS. The actual content of the label is never  
changed, just the CSS. The relevant CSS could look like this:


label:after   { content: :; }
label.required:before { content: *; }
label.error   { font-style: italic;  color: red;}

This will render a : after every field label. When the label's  
class is required, it renders an asterisk in front of the label.  
Obviously a class of error renders the label in red and italic, and  
the neat thing is that you can apply multiple CSS classes by using a  
space separated list of names in your class attribute. So label  
class=error required.../label will render in red and italic,  
with a '*' in front and a ':' at the end.


Sometimes, a field label is used for multiple fields (credit card  
number and 3-digit security code, for example, or a 4x4 digit prepaid  
voucher number field). That's why I added the possiblity to pass an  
array of components to FieldLabel - the label's appearance will  
change based on any field in the array.


cheers,
Gert Jan


---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477alloc_id=16492op=click
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477alloc_id=16492op=click
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] FieldLabel component

2005-07-29 Thread Jonathan Locke


if you just want to show an error indicator like a red asterisk, see 
FormComponentFeedbackBorder.
i personally don't like the idea of changing field label contents on 
users.  so instead, i've emphasized FeedbackPanel and IFeedback.
however, you should be able to implement what you're talking about 
though by implementing IFeedback on a subclass of Label.


Igor Vaynberg wrote:


Hi Guys,

Ive been working on forms a lot lately, and what ive been missing from
tapestry is a fieldlabel component. Basically a fieldlabel is a label that
is linked to a form component.

This allows to do cool things like:

1) FieldLabel can change its apperance based on the form component

TextField tf=new RequiredTextField(...)
FieldLabel lb=new FieldLabel(label1,First Name, tf) {
public void initialize() {
add(new AttributeModifier(style, true, new
Model(color:red;)) {
public boolean isEnabled()
{
return !getFieldComponent().isValid();
}
});
}
};

This will create a field label that will turn red when the linked form
component has an error.

Another good use is to prepand an asterisk to the fieldlabel's label if the
linked form component has a requiredvalidator added.

2) FieldLabel's label can participate in validator messages

With this patch it is possible to create generic error messages of form :

'${label}' is required or '${label}' contains an invalid email address

I am looking for feedback and ideas on how to make this better before I
submit this as a patch.

Thank you!
Igor
 




Index: wicket/markup/html/form/FormComponent.java
===
RCS file: 
/cvsroot/wicket/wicket/src/java/wicket/markup/html/form/FormComponent.java,v
retrieving revision 1.43
diff -u -r1.43 FormComponent.java
--- wicket/markup/html/form/FormComponent.java  28 Jul 2005 11:56:51 -  
1.43
+++ wicket/markup/html/form/FormComponent.java  30 Jul 2005 02:32:19 -
@@ -30,6 +30,7 @@
import wicket.model.IModel;
import wicket.util.lang.Classes;
import wicket.util.string.StringList;
+import wicket.version.undo.Change;

/**
 * An html form component knows how to validate itself. Validators that
@@ -71,6 +72,9 @@
/** The validator or validator list for this component. */
private IValidator validator = IValidator.NULL;

+   /** The field label for this component */
+   private FieldLabel fieldLabel;
+   
/**
 * Typesafe interface to code that is called when visiting a form 
component
	 * 
@@ -575,4 +579,24 @@

{
validator.validate(this);
}
+   
+   protected FormComponent setFieldLabel(FieldLabel label) {
+   if (fieldLabel!=null) {
+   
+   addStateChange(new Change() {
+   private final FieldLabel 
oldFieldLabel=FormComponent.this.fieldLabel;
+
+   public void undo()
+   {
+   
FormComponent.this.fieldLabel=oldFieldLabel;
+   }
+   });
+   }
+   this.fieldLabel=label;
+   return this;
+   }
+   
+   public FieldLabel getFieldLabel() {
+   return fieldLabel;
+   }
}
\ No newline at end of file
Index: wicket/markup/html/form/validation/AbstractValidator.java
===
RCS file: 
/cvsroot/wicket/wicket/src/java/wicket/markup/html/form/validation/AbstractValidator.java,v
retrieving revision 1.31
diff -u -r1.31 AbstractValidator.java
--- wicket/markup/html/form/validation/AbstractValidator.java   21 Jul 2005 
10:46:36 -  1.31
+++ wicket/markup/html/form/validation/AbstractValidator.java   30 Jul 2005 
02:32:19 -
@@ -21,6 +21,7 @@
import java.util.Map;

import wicket.Localizer;
+import wicket.markup.html.form.FieldLabel;
import wicket.markup.html.form.FormComponent;
import wicket.model.IModel;
import wicket.model.Model;
@@ -139,6 +140,21 @@
final Map resourceModel = new HashMap(4);
resourceModel.put(input, formComponent.getInput());
resourceModel.put(name, formComponent.getId());
+   
+   // try to retrieve the label from field label, default to empty 
string
+   String labelValue = ;
+   FieldLabel label = formComponent.getFieldLabel();
+   if (label != null)
+   {
+   Object modelObject = label.getModelObject();
+   if (modelObject != null)
+   {
+   labelValue = modelObject.toString();
+   }
+   }
+ 

RE: [Wicket-user] FieldLabel component

2005-07-29 Thread Igor Vaynberg
I've seen the error border, it doesn't do what I want - in our app a red
asterisk indicates a required field and field labels with errors turn red.
What I am looking for is a way to link the label to the component not the
other way around. My primary interest was the validator stuff, the
decoration of the label was a bonus.

-Igor


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Jonathan Locke
 Sent: Friday, July 29, 2005 8:14 PM
 To: wicket-user@lists.sourceforge.net
 Subject: Re: [Wicket-user] FieldLabel component
 
 
 if you just want to show an error indicator like a red 
 asterisk, see FormComponentFeedbackBorder.
 i personally don't like the idea of changing field label 
 contents on users.  so instead, i've emphasized FeedbackPanel 
 and IFeedback.
 however, you should be able to implement what you're talking 
 about though by implementing IFeedback on a subclass of Label.
 
 Igor Vaynberg wrote:
 
 Hi Guys,
 
 Ive been working on forms a lot lately, and what ive been 
 missing from 
 tapestry is a fieldlabel component. Basically a fieldlabel 
 is a label 
 that is linked to a form component.
 
 This allows to do cool things like:
 
 1) FieldLabel can change its apperance based on the form component
 
 TextField tf=new RequiredTextField(...) FieldLabel lb=new 
 FieldLabel(label1,First Name, tf) {
  public void initialize() {
  add(new AttributeModifier(style, true, new
 Model(color:red;)) {
  public boolean isEnabled()
  {
  return !getFieldComponent().isValid();
  }
  });
  }
 };
 
 This will create a field label that will turn red when the 
 linked form 
 component has an error.
 
 Another good use is to prepand an asterisk to the 
 fieldlabel's label if 
 the linked form component has a requiredvalidator added.
 
 2) FieldLabel's label can participate in validator messages
 
 With this patch it is possible to create generic error 
 messages of form :
 
 '${label}' is required or '${label}' contains an invalid 
 email address
 
 I am looking for feedback and ideas on how to make this 
 better before I 
 submit this as a patch.
 
 Thank you!
 Igor
   
 
 -
 --
 -
 
 Index: wicket/markup/html/form/FormComponent.java
 ===
 RCS file: 
 /cvsroot/wicket/wicket/src/java/wicket/markup/html/form/FormC
 omponent.j
 ava,v
 retrieving revision 1.43
 diff -u -r1.43 FormComponent.java
 --- wicket/markup/html/form/FormComponent.java   28 Jul 
 2005 11:56:51 -   1.43
 +++ wicket/markup/html/form/FormComponent.java   30 Jul 
 2005 02:32:19 -
 @@ -30,6 +30,7 @@
  import wicket.model.IModel;
  import wicket.util.lang.Classes;
  import wicket.util.string.StringList;
 +import wicket.version.undo.Change;
  
  /**
   * An html form component knows how to validate itself. Validators 
 that @@ -71,6 +72,9 @@
  /** The validator or validator list for this component. */
  private IValidator validator = IValidator.NULL;
  
 +/** The field label for this component */
 +private FieldLabel fieldLabel;
 +
  /**
   * Typesafe interface to code that is called when 
 visiting a form component
   *
 @@ -575,4 +579,24 @@
  {
  validator.validate(this);
  }
 +
 +protected FormComponent setFieldLabel(FieldLabel label) {
 +if (fieldLabel!=null) {
 +
 +addStateChange(new Change() {
 +private final FieldLabel 
 +oldFieldLabel=FormComponent.this.fieldLabel;
 +
 +public void undo()
 +{
 +
 FormComponent.this.fieldLabel=oldFieldLabel;
 +}
 +});
 +}
 +this.fieldLabel=label;
 +return this;
 +}
 +
 +public FieldLabel getFieldLabel() {
 +return fieldLabel;
 +}
  }
 \ No newline at end of file
 Index: wicket/markup/html/form/validation/AbstractValidator.java
 ===
 RCS file: 
 /cvsroot/wicket/wicket/src/java/wicket/markup/html/form/valid
 ation/Abst
 ractValidator.java,v
 retrieving revision 1.31
 diff -u -r1.31 AbstractValidator.java
 --- 
 wicket/markup/html/form/validation/AbstractValidator.java 
 21 Jul 2005 10:46:36 -1.31
 +++ 
 wicket/markup/html/form/validation/AbstractValidator.java 
 30 Jul 2005 02:32:19 -
 @@ -21,6 +21,7 @@
  import java.util.Map;
  
  import wicket.Localizer;
 +import wicket.markup.html.form.FieldLabel;
  import wicket.markup.html.form.FormComponent;
  import wicket.model.IModel;
  import wicket.model.Model;
 @@ -139,6 +140,21 @@
  final Map resourceModel = new HashMap(4

Re: [Wicket-user] FieldLabel component

2005-07-29 Thread Jonathan Locke


well, i don't know what's happened to the feedback interface stuff recently,
but it was originally designed to be general enough to support what you're
trying to do.   seems like what you're writing is more or less a 
FormComponentFeedbackLabel.  and the link is simply implementing IFeedback
(or it used to be... i'm not sure what's changed... it looks unfamiliar 
now).
the form code then finds the associated feedback elements for each form 
component.


Igor Vaynberg wrote:


I've seen the error border, it doesn't do what I want - in our app a red
asterisk indicates a required field and field labels with errors turn red.
What I am looking for is a way to link the label to the component not the
other way around. My primary interest was the validator stuff, the
decoration of the label was a bonus.

-Igor


 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Jonathan Locke

Sent: Friday, July 29, 2005 8:14 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] FieldLabel component


if you just want to show an error indicator like a red 
asterisk, see FormComponentFeedbackBorder.
i personally don't like the idea of changing field label 
contents on users.  so instead, i've emphasized FeedbackPanel 
and IFeedback.
however, you should be able to implement what you're talking 
about though by implementing IFeedback on a subclass of Label.


Igor Vaynberg wrote:

   


Hi Guys,

Ive been working on forms a lot lately, and what ive been 
 

missing from 
   

tapestry is a fieldlabel component. Basically a fieldlabel 
 

is a label 
   


that is linked to a form component.

This allows to do cool things like:

1) FieldLabel can change its apperance based on the form component

TextField tf=new RequiredTextField(...) FieldLabel lb=new 
FieldLabel(label1,First Name, tf) {

public void initialize() {
add(new AttributeModifier(style, true, new
Model(color:red;)) {
public boolean isEnabled()
{
return !getFieldComponent().isValid();
}
});
}
};

This will create a field label that will turn red when the 
 

linked form 
   


component has an error.

Another good use is to prepand an asterisk to the 
 

fieldlabel's label if 
   


the linked form component has a requiredvalidator added.

2) FieldLabel's label can participate in validator messages

With this patch it is possible to create generic error 
 


messages of form :
   

'${label}' is required or '${label}' contains an invalid 
 


email address
   

I am looking for feedback and ideas on how to make this 
 

better before I 
   


submit this as a patch.

Thank you!
Igor


-
 


--
   


-

Index: wicket/markup/html/form/FormComponent.java
===
RCS file: 
/cvsroot/wicket/wicket/src/java/wicket/markup/html/form/FormC
 


omponent.j
   


ava,v
retrieving revision 1.43
diff -u -r1.43 FormComponent.java
--- wicket/markup/html/form/FormComponent.java	28 Jul 
 


2005 11:56:51 - 1.43
   

+++ wicket/markup/html/form/FormComponent.java	30 Jul 
 


2005 02:32:19 -
   


@@ -30,6 +30,7 @@
import wicket.model.IModel;
import wicket.util.lang.Classes;
import wicket.util.string.StringList;
+import wicket.version.undo.Change;

/**
* An html form component knows how to validate itself. Validators 
that @@ -71,6 +72,9 @@

/** The validator or validator list for this component. */
private IValidator validator = IValidator.NULL;

+   /** The field label for this component */
+   private FieldLabel fieldLabel;
+   
/**
	 * Typesafe interface to code that is called when 
 


visiting a form component
   


 *
@@ -575,4 +579,24 @@
{
validator.validate(this);
}
+   
+   protected FormComponent setFieldLabel(FieldLabel label) {
+   if (fieldLabel!=null) {
+   
+   addStateChange(new Change() {
+private final FieldLabel 
+oldFieldLabel=FormComponent.this.fieldLabel;

+
+   public void undo()
+   {
+   
 


FormComponent.this.fieldLabel=oldFieldLabel;
   


+   }
+   });
+   }
+   this.fieldLabel=label;
+   return this;
+   }
+   
+   public FieldLabel getFieldLabel() {
+   return fieldLabel;
+   }
}
\ No newline at end of file
Index: wicket/markup/html/form/validation/AbstractValidator.java
===
RCS file: 
/cvsroot/wicket/wicket/src/java/wicket/markup/html/form/valid
 


ation