Use NameableTextField.setLabel(model)

On Sat, Jan 8, 2011 at 12:16 PM, Arjun Dhar <[email protected]> wrote:

>
> Hi,
>  I have a form where the number of fields are not fixed so have a Loop
> where
> i add the fields. All these are mandatory. In a loop, your field id is
> keeps
> the same AFAIK. So when there is a validation error the standard message
> mentions the component id ..which isnt good enough in a loop, like this:
>
>
>                ListView horizontalSegments = new
> ListView<HorizontalSegment>("horizontalSegments", hsegs) {
>                        @Override
>                        protected void
> populateItem(ListItem<HorizontalSegment> item) {
>                                String key =
> item.getModelObject().getDisplayName();
>                                item.add(new Label("name", key));
>                                item.add(new
> NameableTextField<Double>("value",
>                                                new
> Model(getMeasurementValue(mp.getHorizontalMeasurements(),
> item.getModelObject())),
>                                                Double.class,
> MarshalUtils.toAlphaNumeric(item.getModelObject().name()))
>                                                .setRequired(true));
>                        }
>                };
>                add(horizontalSegments);
>
>
> When I submit the form and say 5 of them are blank. I get 5 messages saying
> "Field 'value' is required."
> Thats understandable because the "FeebackMessage" in the FeedbackPanel
> feeds
> of the component ID.
>
> While debugging I see FeedbackMessage apparently maintains some reference
> to
> the 'Reporter'.
> When I look at the code I see a ton of final methods etc, and having some
> trouble modifying the method that creates the message. My reporter
> component
> (NameableTextField) knows the correct name.
>
> Can someone provide simple way of overriding that message
>
> thank you.
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-messages-in-a-Loop-Dynamic-Form-tp3204893p3204893.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to