You can easily... here is a simple example, you can improvize from there:
public class FeedbackStyler extends AttributeModifier {
/**
* @param formComponent
* @return FormComponent<?>
*/
public static FormComponent<?> add(FormComponent<?> formComponent) {
formComponent.add(new FeedbackStyler(formComponent));
return formComponent;
}
/**
* @param formComponent
*/
private FeedbackStyler(FormComponent formComponent) {
this(formComponent, null);
}
/**
* @param formComponent
* @param defaultStyle
*/
public FeedbackStyler(FormComponent formComponent, String defaultStyle) {
super(WebPageConstants.STYLE, true, new
FeedbackStyleModel(formComponent, defaultStyle));
}
/**
* @see
org.apache.wicket.AttributeModifier#isEnabled(org.apache.wicket.Component)
*/
@Override
public boolean isEnabled(Component component) {
return !Utils.isEmpty((String) getReplaceModel().getObject());
}
}
public class FeedbackStyleModel extends AbstractReadOnlyModel<String> {
private final FormComponent<?> formComponent;
private String defaultStyle;
private ComponentFeedbackMessageFilter componentFeedbackMessageFilter;
/**
* @param formComponent
* @param defaultStyle
*/
public FeedbackStyleModel(FormComponent<?> formComponent, String
defaultStyle) {
this.formComponent = formComponent;
this.defaultStyle = defaultStyle;
}
/**
* @see org.apache.wicket.model.AbstractReadOnlyModel#getObject()
*/
@Override
public String getObject() {
boolean inError = 0 < TakpSession.get().getFeedbackMessages().messages(
getComponentFeedbackMessageFilter()).size();
if (inError) {
return "border: red solid 1px;" + Utils.noNull(getDefaultStyle());
}
return "" + Utils.noNull(getDefaultStyle());
}
/**
* @return IFeedbackMessageFilter
*/
protected IFeedbackMessageFilter getComponentFeedbackMessageFilter() {
if (componentFeedbackMessageFilter == null) {
componentFeedbackMessageFilter = new ComponentFeedbackMessageFilter(
formComponent);
}
return componentFeedbackMessageFilter;
}
/**
* @return the defaultStyle
*/
public String getDefaultStyle() {
return defaultStyle;
}
/**
* @param defaultStyle
* the defaultStyle to set
*/
public void setDefaultStyle(String defaultStyle) {
this.defaultStyle = defaultStyle;
}
}
**
Martin
2009/1/13 walnutmon <[email protected]>:
>
> This leaves one thing out of the problem though. Because FeedbackIndicator
> is a panel, it still needs some HTML markup, and I am trying to avoid adding
> a dozens of feedback panels to the markup and java code. However, I'm also
> confident that there is some way to accomplish this. I was thinking, you
> could make a custom panel which always includes a feedback component. But
> that would require me to change all of my add(new TextField(...)); to a
> add(new FeedbackTextField()); and also have to change some of the
> corresponding markup to remove the references to "<input>" instead
> converting them all to "" elements.
>
> Thanks!
> Justin
>
>
>
> Martin Makundi wrote:
>>
>> Hi!
>>
>> There are:
>> * FormComponentFeedbackBorder
>> * FormComponentFeedbackIndicator
>>
>> ... and you can also make your own, it is easy to react to the
>> feedback message status of a component and just make your own effect.
>> Have a look at the source code within the abovementioned...
>>
>> **
>> Martin
>>
>> 2009/1/13 walnutmon <[email protected]>:
>>>
>>> All,
>>>
>>> I have a page with many form components, nearly all of them have some
>>> kind
>>> of validation associated with them. I have a feedback panel at the top,
>>> I'd
>>> like to move feedback next to each component. I have thought of some
>>> ways
>>> to do this without changing a ton of code, however none really work in
>>> the
>>> end because I would still need to add some kind of HTML in order to
>>> display
>>> messages.
>>>
>>> Also, nearly everything like this that I have developed in wicket is
>>> usually
>>> accompanied by the discovery that wicket already has the functionality
>>> I'm
>>> looking for out of the box. Searching has given me surprisingly little
>>> with
>>> regard to this topic though. Can someone point me in the right
>>> direction?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Form-Components-With-Built-In-Feedback-tp21443674p21443674.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Form-Components-With-Built-In-Feedback-tp21443674p21444965.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]