You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kshitiz <k....@gmail.com> on 2012/03/21 15:56:45 UTC

Error in dynamic form with any number of drop down ,enu

Hi,

I want to create a form where user can have any number of drop down menus.
Here is my code:

*private ListView<DropDownChoice&lt;String>> organizationList;*
public Register() throws InvalidEmailException, Exception
	{
		add(new FeedbackPanel("feedbackPanel"));
		final DropDownChoice<String> organizationDropDown = new
DropDownChoice<String>(
				"organizations", new PropertyModel<String>(this, "selected"),
SEARCH_ENGINES);
		StatelessForm <Register> registerForm = new StatelessForm
<Register>("registerForm", new CompoundPropertyModel<Register>(userDomain));
		add(registerForm);
		Label nameLabel = new Label("nameLabel", "Name");    
        registerForm.add(nameLabel);
        RequiredTextField<String> nameField = new
RequiredTextField<String>("name", new PropertyModel<String>(this, "name"));
       
nameField.add(LengthBetweenValidator.lengthBetween(MIN_LOCATION_NAME_LENGTH,
MAX_LOCATION_NAME_LENGTH));
        registerForm.add(nameField);
        
        *this.add(organizationList = new ListView("organizationList") {
        	
            /**
					 * 
					 */
					private static final long serialVersionUID = 1L;

			@Override 
            protected void populateItem(final ListItem item) {  
                item.add(organizationDropDown); 
              
            } 
        }); *

    

        
        
        Button submitButton = new Button("submitButton") {          
            @Override
            public void onSubmit() {
            	info("Selected search engine : " + selected);
            	System.out.println(selected);
            	organizationList.add(organizationDropDown);
            }
        };
        
                registerForm.add(submitButton);
        
		
	}



And my html files is:

<form wicket:id="registerForm">
              <div>
                 <label for="name" wicket:id="nameLabel">Name</label> <input
type="text" id="name" wicket:id="name"/>
                * <tr wicket:id="organizationList"> 
                 <td><select wicket:id="organizations"></select></td>
                 </tr>*
             
                 <input type="submit" value="Register" class="formbutton"
name="Register" wicket:id="submitButton"/> 
              </div>
            </form>


But I am getting the error:
*Unable to find component with id 'organizationList' in [MarkupContainer
[Component id = registerForm]]. *

I have followed the same procedure as given in various examples in google.
So what is the cause of error?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-in-dynamic-form-with-any-number-of-drop-down-enu-tp4492543p4492543.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: Error in dynamic form with any number of drop down ,enu

Posted by Michal Wegrzyn <mi...@onior.com>.
Hi,

You should add "organizationList" to the registerForm object.

Best regards,
Michal Wegrzyn

> -----Original Message-----
> From: kshitiz [mailto:k.agarwal4@gmail.com]
> Sent: Wednesday, March 21, 2012 15:57
> To: users@wicket.apache.org
> Subject: Error in dynamic form with any number of drop down ,enu
> 
> Hi,
> 
> I want to create a form where user can have any number of drop down
> menus.
> Here is my code:
> 
> *private ListView<DropDownChoice&lt;String>> organizationList;* public
> Register() throws InvalidEmailException, Exception
> 	{
> 		add(new FeedbackPanel("feedbackPanel"));
> 		final DropDownChoice<String> organizationDropDown = new
> DropDownChoice<String>(
> 				"organizations", new
> PropertyModel<String>(this, "selected"), SEARCH_ENGINES);
> 		StatelessForm <Register> registerForm = new StatelessForm
> <Register>("registerForm", new
> CompoundPropertyModel<Register>(userDomain));
> 		add(registerForm);
> 		Label nameLabel = new Label("nameLabel", "Name");
>         registerForm.add(nameLabel);
>         RequiredTextField<String> nameField = new
> RequiredTextField<String>("name", new PropertyModel<String>(this,
> "name"));
> 
> nameField.add(LengthBetweenValidator.lengthBetween(MIN_LOCATION_NAME_LE
> NGTH,
> MAX_LOCATION_NAME_LENGTH));
>         registerForm.add(nameField);
> 
>         *this.add(organizationList = new ListView("organizationList") {
> 
>             /**
> 					 *
> 					 */
> 					private static final long
> serialVersionUID = 1L;
> 
> 			@Override
>             protected void populateItem(final ListItem item) {
>                 item.add(organizationDropDown);
> 
>             }
>         }); *
> 
> 
> 
> 
> 
>         Button submitButton = new Button("submitButton") {
>             @Override
>             public void onSubmit() {
>             	info("Selected search engine : " + selected);
>             	System.out.println(selected);
>             	organizationList.add(organizationDropDown);
>             }
>         };
> 
>                 registerForm.add(submitButton);
> 
> 
> 	}
> 
> 
> 
> And my html files is:
> 
> <form wicket:id="registerForm">
>               <div>
>                  <label for="name" wicket:id="nameLabel">Name</label>
> <input type="text" id="name" wicket:id="name"/>
>                 * <tr wicket:id="organizationList">
>                  <td><select wicket:id="organizations"></select></td>
>                  </tr>*
> 
>                  <input type="submit" value="Register"
> class="formbutton"
> name="Register" wicket:id="submitButton"/>
>               </div>
>             </form>
> 
> 
> But I am getting the error:
> *Unable to find component with id 'organizationList' in
> [MarkupContainer [Component id = registerForm]]. *
> 
> I have followed the same procedure as given in various examples in
> google.
> So what is the cause of error?
> 
> --
> View this message in context: http://apache-
> wicket.1842946.n4.nabble.com/Error-in-dynamic-form-with-any-number-of-
> drop-down-enu-tp4492543p4492543.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


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


Re: Error in dynamic form with any number of drop down ,enu

Posted by kshitiz <k....@gmail.com>.
Thank you for the link....the error is gone but now, drop down is not gtting
displayed...what could be the reason...surely organizationList is not
getting populated with dropdownchoice component but why?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-in-dynamic-form-with-any-number-of-drop-down-enu-tp4492543p4496153.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: Error in dynamic form with any number of drop down ,enu

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Your code:
  StatelessForm <Register> registerForm = new StatelessForm
<Register>("registerForm", new CompoundPropertyModel<Register>(userDomain));
...
registerForm.add(organizationList = new ListView("organizationList") {

since organizationList has no its own model it asks its parent for a
model. Since the parent uses CompoundPropertyModel it tries to find
userDomain.organizationList bean property. Check CompoundPropertyModel
javadoc. Also https://cwiki.apache.org/WICKET/working-with-wicket-models.html

On Thu, Mar 22, 2012 at 7:58 AM, kshitiz <k....@gmail.com> wrote:
> Hi, what is the relation between userdomain and organizationList as shown in
> the error...i have searched my things in internet but I am not able to
> understand...the problem is related to dropdownchoice declaration so where
> userdomain comes into picture??
>
> Please help me...
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-in-dynamic-form-with-any-number-of-drop-down-enu-tp4492543p4494681.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
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Error in dynamic form with any number of drop down ,enu

Posted by kshitiz <k....@gmail.com>.
Hi, what is the relation between userdomain and organizationList as shown in
the error...i have searched my things in internet but I am not able to
understand...the problem is related to dropdownchoice declaration so where
userdomain comes into picture??

Please help me...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-in-dynamic-form-with-any-number-of-drop-down-enu-tp4492543p4494681.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: Error in dynamic form with any number of drop down ,enu

Posted by kshitiz <k....@gmail.com>.
Sorry..I missed to add *registerForm.add(organizationList);* in java class.
After adding that with proper getters and setters..I am getting the error:

WicketMessage: No get method defined for class: class domain.UserDomain
expression: organizationList

Root cause:

org.apache.wicket.WicketRuntimeException: No get method defined for class:
class domain.UserDomain expression: organizationList
     at
org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:499)
...

What is the reason ... I have added getters and setters...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-in-dynamic-form-with-any-number-of-drop-down-enu-tp4492543p4492627.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