What about generic validator messages - this is more important then the look and feel of the label which I can achieve in a thousand different ways.
Using this model it is not possible to generically identify which Ifeedback belongs to which FormComponent. And what if there are more then one - how do I know which one to query for the label? And I still have to cast Ifeedback to Component in order to retrieve the model used for the label. Igor > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Jonathan Locke > Sent: Saturday, July 30, 2005 1:04 AM > To: wicket-user@lists.sourceforge.net > Subject: [Wicket-user] Feedback Refactor Idea > > > at this point, it looks like it would make more sense to me > to break with compatibility and change IFeedback to something > more like this: > > interface IFeedback > { > public void updateFeedback(); > } > > then have the framework call updateFeedback() on each > IFeedback implementing component on the page at the > appropriate time (probably onBeginRequest(), but subject to > implementation details). > > then we can implement any kind of feedback component that we > want to. > igor can implement like this: > > public class FormComponentFeedbackLabel extends Label > implements IFeedback { > FormComponent component; > > public FormComponentFeedbackLabel(FormComponent component) > { > this.component = component; > } > > public void updateFeedback() > { > // Set label look and feel based on any error in component > } > } > > FormComponentErrorIndicator would be similar, showing/hiding > its content on error. And FeedbackPanel and > FormComponentFeedbackBorder would do their recursive magic in update() > > so now every feedback component is "pull model" and updated > at the appropriate time by implementing updateFeedback(). > best of all, the component can do absolutely anything based > on the state of any other components passed in to whatever > constructor the feedback component has... > > doesn't this seem a whole lot simpler and more flexible? > > Jonathan Locke wrote: > > > > > 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, 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 -0000 1.43 > >>>>>> > >>>>>> > >>>>>> > >>>>>>> +++ wicket/markup/html/form/FormComponent.java 30 > Jul > >>>>>> > >>>>>> > >>>>>> 2005 02:32:19 -0000 > >>>>>> > >>>>>> > >>>>>> > >>>>>>> @@ -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 -0000 1.31 > >>>>>> > >>>>>> > >>>>>> > >>>>>>> +++ > >>>>>> > >>>>>> > >>>>>> wicket/markup/html/form/validation/AbstractValidator.java 30 > >>>>>> Jul 2005 02:32:19 -0000 > >>>>>> > >>>>>> > >>>>>> > >>>>>>> @@ -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(); > >>>>>>> + } > >>>>>>> + } > >>>>>>> + resourceModel.put("label", labelValue); > >>>>>>> + + return resourceModel; > >>>>>>> } > >>>>>>> } > >>>>>>> Index: wicket/markup/html/form/FieldLabel.java > >>>>>>> > ================================================================ > >>>>>>> === RCS file: wicket/markup/html/form/FieldLabel.java > >>>>>>> diff -N wicket/markup/html/form/FieldLabel.java > >>>>>>> --- /dev/null 1 Jan 1970 00:00:00 -0000 > >>>>>>> +++ wicket/markup/html/form/FieldLabel.java 1 Jan 1970 > >>>>>>> > >>>>>> > >>>>>> > >>>>>> 00:00:00 -0000 > >>>>>> > >>>>>> > >>>>>> > >>>>>>> @@ -0,0 +1,55 @@ > >>>>>>> +package wicket.markup.html.form; > >>>>>>> + > >>>>>>> +import wicket.AttributeModifier; import wicket.Component; > >>>>>>> +import wicket.markup.html.WebMarkupContainer; > >>>>>>> +import wicket.markup.html.basic.Label; import > >>>>>>> +wicket.markup.html.panel.Panel; import > >>>>>> > >>>>>> > >>>> wicket.model.IModel; import > >>>> > >>>>>>> +wicket.model.Model; import wicket.model.PropertyModel; > >>>>>>> + > >>>>>>> +public class FieldLabel extends Label { > >>>>>>> + protected FormComponent fc; > >>>>>>> + + public FieldLabel(String id, FormComponent > formComponent) > >>>>>>> + { > >>>>>>> + super(id); > >>>>>>> + internalInitialize(formComponent); > >>>>>>> + } > >>>>>>> + > >>>>>>> + public FieldLabel(String id, String string, > >>>>>>> > >>>>>> > >>>>>> > >>>>>> FormComponent formComponent) > >>>>>> > >>>>>> > >>>>>> > >>>>>>> + { > >>>>>>> + super(id, string); > >>>>>>> + internalInitialize(formComponent); > >>>>>>> + } > >>>>>>> + + public FieldLabel(String id, IModel model, > >>>>>>> > >>>>>> > >>>>>> > >>>>>> FormComponent formComponent) > >>>>>> > >>>>>> > >>>>>> > >>>>>>> + { > >>>>>>> + super(id, model); > >>>>>>> + internalInitialize(formComponent); > >>>>>>> + } > >>>>>>> + > >>>>>>> + private void internalInitialize(FormComponent > formComponent) > >>>>>>> + { > >>>>>>> + if (fc==null) throw new > >>>>>>> > >>>>>> > >>>>>> > >>>>>> IllegalArgumentException("formComponent cannot be null"); > >>>>>> > >>>>>> > >>>>>> > >>>>>>> + this.fc=fc; > >>>>>>> + > >>>>>>> + fc.setFieldLabel(this); > >>>>>>> + setRenderBodyOnly(true); > >>>>>>> + + initialize(); > >>>>>>> + } > >>>>>>> + > >>>>>>> + public final FormComponent getFormComponent() { > >>>>>>> + return fc; > >>>>>>> + } > >>>>>>> + + public void initialize() { > >>>>>>> + + } > >>>>>>> + + > >>>>>>> + +} > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>> > >>>>>> > >>>>>> ------------------------------------------------------- > >>>>>> 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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=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=7477&alloc_id=16492&op=click _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user