How to clear autoComplete textfield in Wicket after submit?

2013-09-09 Thread eaglei22


I'm having issues clearing the input of a autoComplete Textfield.. For some
reason whenever I call target.add(reference to AutoCompleteTextField);

my input values are null...

So basically, I can clear the referenced string the input is stored in, but
everytime I call an ajaxupdate it nulls.

I tried both ajaxButton, and AjaxSubmitLink. Both get the same reactions. I
have a button to submit the input from the textField.

Code:

form wicket:id=autoCompleteForm
input wicket:id=autoCompleteTextField size=20/
button width:100px wicket:id=selectRoleBtnSelect/button   
 
/form


private void autoCompleteForm()
{
findRoleForm = new FormVoid(autoCompleteForm);
findRoleForm.setOutputMarkupId(true);
addOrReplace(findRoleForm);
field = new AutoCompleteTextFieldString(autoCompleteTextField,
new PropertyModelString(this,autoString))
{
@Override
protected IteratorString getChoices(String input)
{
if (Strings.isEmpty(input))
{
ListString emptyList = Collections.emptyList();
return emptyList.iterator();
}

ListString choices = new ArrayListString(10);

for (final Role role : rolesList)
{

final String roles = role.getRoleName();

if (roles.toUpperCase().startsWith(input.toUpperCase()))
{
choices.add(roles);
if (choices.size() == 10)
{
break;
}
}
}

return choices.iterator();
}
};
findRoleForm.addOrReplace(field);
findRoleForm.addOrReplace(new AjaxSubmitLink(selectRoleBtn,
findRoleForm)
{
protected void onSubmit(AjaxRequestTarget target, Form? form)
{
System.out.println(here1 + autoString);
if(rolesList  != null  autoString!= null)
{
if(rolesList .size() != 0)
{   
for(int i=0; i  rolesList .size(); i++)
{
System.out.println(here2 + autoString);
if(rolesList
.get(i).getRoleName().equals(autoString))
{
role = rolesList.get(i);

roleInformation.addOrReplace(new
Label(roleNameTxt, role.getRoleName()));
roleInformation.addOrReplace(new
Label(roleAliasTxt, role.getRoleAlias()));
roleInformation.addOrReplace(new
Label(roleOwnerTxt, role.getRoleOwnerId()));
roleInformation.addOrReplace(new
Label(roleStatusTxt, role.getRoleAccessStatus()));
roleInformation.addOrReplace(new
Label(roleCategoryTxt, role.getRoleCategoryName()));
roleInformation.addOrReplace(new
Label(roleDescriptionTxt, role.getRoleDescription()));
roleInformation.addOrReplace(new
Label(roleValidityTxt, role.getRoleValidityStatus()));
roleInformation.addOrReplace(new
Label(roleNumUsers, ));


//add adOrReplace(findRoleForm);
autoString = ;
target.add(field);
target.add(roleInformation);
currentRoleSelection = null;
target.add(rolesDropDownChoice);
break;
}
}
}
   }
}
}).add(getIndicatorAppender());
}





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-clear-autoComplete-textfield-in-Wicket-after-submit-tp4661268.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: How to clear autoComplete textfield in Wicket after submit?

2013-09-09 Thread eaglei22
To add: The autoCompleteTextField input field clears the first time, but when
I try it again. The string: autoString will be null. So if you choose your
selection on first attempt (from the search list provided), hit select
button, it gives you the correct string and clears. But when you do it for a
second time, selected a provided value, the autoString will be null.. and
will not get the input value assigned to it.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-clear-autoComplete-textfield-in-Wicket-after-submit-tp4661268p4661269.html
Sent from the Users forum mailing list archive at Nabble.com.

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