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="selectRoleBtn">Select</button>
</form>
private void autoCompleteForm()
findRoleForm = new Form<Void>("autoCompleteForm");
findRoleForm.setOutputMarkupId(true);
addOrReplace(findRoleForm);
field = new AutoCompleteTextField<String>("autoCompleteTextField",
new PropertyModel<String>(this,"autoString"))
@Override
protected Iterator<String> getChoices(String input)
if (Strings.isEmpty(input))
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
List<String> choices = new ArrayList<String>(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());
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="selectRoleBtn">Select</button>
</form>
private void autoCompleteForm()
findRoleForm = new Form<Void>("autoCompleteForm");
findRoleForm.setOutputMarkupId(true);
addOrReplace(findRoleForm);
field = new AutoCompleteTextField<String>("autoCompleteTextField",
new PropertyModel<String>(this,"autoString"))
@Override
protected Iterator<String> getChoices(String input)
if (Strings.isEmpty(input))
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
List<String> choices = new ArrayList<String>(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());