you are correct, i removed the @Bindable annotation and everything
works as expected.

Thanks,
Curt


On Mon, Feb 28, 2011 at 9:42 AM, Bob Schellink <[email protected]> wrote:
> Hi Curt,
>
> I notice you add the form to the model but you also declare the Form as 
> @Bindable?
>
> @Bindable only works on pages so you need to use the normal route for adding 
> controls (in fact I
> recommend you stay clear of @Bindable even for pages, as it confuses folks)
>
>  Form form = new Form("form");
>  add(form);
>
> Hope this helps.
>
> Bob
>
> On 2011/02/28 17:03 PM, Curt Larson wrote:
>> Hello,
>>
>> I recently moved some code from a page into a panel, and now my ajax
>> auto complete component is no longer working because Click isnt adding
>> the correct *.css and *.js imports now.  Does anyone have any idea
>> what Im doing wrong?  Here is the code from he original Page, that i
>> copy/pasted into a new panel.
>>
>> i guess i could manually add the imports in the new panel, but i would
>> rather understand whats happening and let Click handle the imports
>> automatically.
>>
>> Thanks,
>> Curt
>>
>> -----------------------------------------------------------------------------
>>
>> public class FactPage extends BaseSecurePage {
>>
>>       private static final long serialVersionUID = 1L;
>>
>>       @Inject public PostService postService;
>>       @Inject public TagService tagService;
>>       @Bindable public Form form = new Form();
>>
>>
>>       @Override
>>       public void onInit() {
>>
>>               addModel("form", form);
>>
>>               TextField textField = new TextField("title", 
>> getMessage("formTitle"), true);
>>               textField.setMaxLength(120);
>>               textField.setSize(60);
>>               form.add(textField);
>>
>>               TextArea textArea = new TextArea("body", 
>> getMessage("formBody"));
>>               textArea.setRequired(true);
>>               textArea.setCols(60);
>>               textArea.setRows(10);
>>               form.add(textArea);
>>
>>               TagsAutoCompleteLookup tags =
>>                       new TagsAutoCompleteLookup("tagList", 
>> getMessage("formTaglist"),
>> true, tagService);
>>               form.add(tags);
>>
>>                if(getContext().getApplicationMode().equals("development"))
>>                 form.add(new 
>> Label("captcha",getMessage("captchaNotRequired")));
>>                else
>>                 form.add(new Label("captcha", UtilService.printCaptcha()));
>>
>>
>>               form.add(new Submit("save", "  Save  ", this, "onSaveClick"));
>>               form.add(new Submit("reset", "  Reset  ", this, 
>> "onResetClick"));
>>
>>               super.onInit();
>>       }
>>
>>         .....
>>
>> }
>>
>>
>> /////////////////////////////////////////////////////////////////////////////////////////////////
>>
>> public class TagsAutoCompleteLookup extends AutoCompleteTextField {
>>
>>               private static final long serialVersionUID = 1L;
>>               //private static Logger logger =
>> Logger.getLogger(TagsAutoCompleteLookup.class);
>>
>>               TagService tagService = null;
>>
>>               public TagsAutoCompleteLookup(String name, String title, 
>> boolean
>> required, TagService tagService){
>>                       super(name, title, required);
>>
>>                       setSize(60);
>>                       setMaxLength(Constants.TAG_LIST_LENGTH); //30 chars 
>> per tag, 10
>> tags, 9 commas
>>
>>                       this.tagService = tagService;
>>               }
>>
>>
>>               public List<String> getAutoCompleteList(String criteria) {
>>                       String post = criteria;
>>                       String pre = null;
>>                       List<String> temp = new ArrayList<String>();
>>                       List<String> results = new ArrayList<String>();
>>                       if(criteria != null && criteria.length() >= 1){
>>
>>                               //clean out any illegal chars
>>                               criteria = TagServiceImpl.scrubInput(criteria);
>>                               criteria = TagServiceImpl.formatTags(criteria);
>>
>>                               if(criteria.indexOf(",") > 0){
>>                                       pre = criteria.substring(0, 
>> criteria.lastIndexOf(","));
>>                                       post = 
>> criteria.substring(criteria.lastIndexOf(",") + 1);
>>
>>                               }
>>
>>                               //limit to 10 tags or less
>>                               boolean over10 = false;
>>                               String[] split = criteria.split(",");
>>                               if(split != null && split.length > 
>> Constants.TAG_COUNT)
>>                                       over10 = true;
>>
>>                               if(post != null && post.length() >= 1 && 
>> over10 == false)
>>                                       temp = tagService.findTagsLike(post, 
>> new Integer(15));
>>                       }
>>
>>                       if(criteria.indexOf(",") > 0){
>>                               for (String string : temp) {
>>                                       results.add(pre + "," + string);
>>                               }
>>                       }else{
>>                               results = temp;
>>                       }
>>
>>                       return results;
>>           }
>>
>>
>>               @Override
>>               public void validate() {
>>
>>                       boolean result = 
>> TagServiceImpl.isTagListInvalid(getValue());
>>
>>                       if(result){
>>
>>                               if(StringUtils.containsAny(getValue(), 
>> Constants.INVALID_CHARS));
>>                                       
>> form.setError(getMessage("invalidChars"));
>>
>>                               String split[] = getValue().split(",");
>>                               if(split.length > Constants.TAG_COUNT)
>>                                       
>> form.setError(getMessage("tooManyTags"));
>>
>>                               for(int i = 0; i < split.length; i++){
>>                                       if(split[i].length() > 
>> Constants.TAG_LENGTH){
>>                                               
>> form.setError(getMessage("tooLongTag"));
>>                                               break;
>>                                       }
>>                               }
>>                       }
>>
>>                       super.validate();
>>               }
>> }
>>
>
>

Reply via email to