You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arjun Dhar <dh...@yahoo.com> on 2011/01/08 12:16:44 UTC

FeedbackPanel messages in a Loop (Dynamic Form)

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: FeedbackPanel messages in a Loop (Dynamic Form)

Posted by Arjun Dhar <dh...@yahoo.com>.
DOH! (As Mr. Homer Simpson would say)

I forgot about ListView and reuse Items!!

hence by adding this to my loops it worked out:

	        @Override
		public boolean getReuseItems() {	        	
				return true;
		}

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-messages-in-a-Loop-Dynamic-Form-tp3204893p3205716.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: FeedbackPanel messages in a Loop (Dynamic Form)

Posted by Arjun Dhar <dh...@yahoo.com>.
There seems to be another problem.

On error the form values are not retained. The same form also has some
normal fields (outside the loop). The notmal form fields that are NOT in a
loop retain their values (on re-load)

I even removed my own "NameableTextField" and am using standard & simple
"TextField" in the above code but its not retaining the values (when there
are errors). 

Am debugging it but in the mean time if someone has an idea or even a "did
you try this?" please let me know.

P.S: This problem does not seem related to .setLabel(name). Its something
else and has something to do with the components being the loop.

thanks
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-messages-in-a-Loop-Dynamic-Form-tp3204893p3205706.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: FeedbackPanel messages in a Loop (Dynamic Form)

Posted by Arjun Dhar <dh...@yahoo.com>.
Beautiful; it worked. Thank you
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-messages-in-a-Loop-Dynamic-Form-tp3204893p3205636.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: FeedbackPanel messages in a Loop (Dynamic Form)

Posted by Martin Grigorov <mg...@apache.org>.
Use NameableTextField.setLabel(model)

On Sat, Jan 8, 2011 at 12:16 PM, Arjun Dhar <dh...@yahoo.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>