Did you know the
ApplicationSettings.setThrowExceptionOnMissingResource setting? If you
set this to false, you don't have to provide the messages. This
combined with IFeedbackMessageFilter or just not adding a
feedback(panel) alltogether acchieves the same - I think - as what you
did?

Eelco

On 10/15/05, Ralf Ebert <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I just changed some of my forms to show form validation results
> without messages (I was fed of writing these property files). I just
> want form fields with validation errors getting a special css class
> (for eye catching formatting) and a general message like "check the
> marked fields". I got that working in a general way, just thought I
> should tell you about this use case and how I got that working
> because I think it's a quite common technique and Wicket could
> support it out of the box...
> I think the fact that the Validators know about messages currently is
> not the greatest approach because validation doesn't depend on
> messages in general. Maybe validation and reacting on validation
> errors could be separated a bit more.
>
>
> === Ok, at first I got rid of the need to supply a message for each
> form field:
>
>          getSettings().addStringResourceLoader(new
> IStringResourceLoader() {
>
>              public String loadStringResource(Component component,
> String key, Locale locale, String style) {
>                  if (key.endsWith("Validator"))
>                      return "Please enter a valid value for
> "+component.getId()+"!";
>                  return null;
>              }
>
>          });
>
>
> === Second thing: A form class that adds a AttributeModifier to all
> form components:
>
> public class HighlightForm extends Form {
>
>      private final static AttributeModifier
> highlightAttributeModifier = new AttributeModifier("class", true, new
> AbstractReadOnlyModel() {
>
>          public Object getObject(Component component) {
>              if (component.hasErrorMessage())
>                  return "error";
>              return null;
>          }
>
>      });
>
>      @Override
>      protected void onBeginRequest() {
>          visitFormComponents(new FormComponent.IVisitor() {
>
>              public void formComponent(FormComponent formComponent) {
>                  formComponent.add(highlightAttributeModifier);
>              }
>
>          });
>      }
>
>      public HighlightForm(String id, IModel model) {
>          super(id, model);
>      }
>
>      public HighlightForm(String id) {
>          super(id);
>      }
>
> }
>
> === Third thing, a feedback markup container that is shown only when
> there was a validation error (message can be specified in the markup
> this way)
>
> public class SimpleFeedbackPanel extends WebMarkupContainer
> {
>
>      /**
>       * @see wicket.Component#Component(String)
>       */
>      public SimpleFeedbackPanel(final String id)
>      {
>          super(id);
>          setModel(new FeedbackMessagesModel());
>      }
>
>      @Override
>      public boolean isVisible() {
>          return !((List) getModelObject()).isEmpty();
>      }
>
> }
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Wicket-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
>


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to