Adding ListMultipleChoice as Custom Field

Help
2011-02-03
2013-05-01
  • vedbharathi ved

    vedbharathi ved - 2011-02-03

    I trying to add ListMultipleChoice as Custom Field.  I created the field as String in the Items and History table so that data can be stored as comma separated string  .  I am having problem when I am trying to edit the item. I am getting error:-
    2011-02-02 17:51:06,100  ERROR  - Model object for a ListMultipleChoice must be a Collection (found class java.lang.String)
    org.apache.wicket.WicketRuntimeException: Model object for a ListMultipleChoice must be a Collection (found class java.lang.String)
    at org.apache.wicket.markup.html.form.ListMultipleChoice.getModelValue(ListMultipleChoice.java:190)
    at org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:744)
    at org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:344)
    at org.apache.wicket.Component.renderComponent(Component.java:2459)
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1354)
    at org.apache.wicket.Component.render(Component.java:2296)
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1240)
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1407)
    at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1344)
    at org.apache.wicket.Component.renderComponent(Component.java:2459)

    SOMETHING HERE
    [code]
     else if (field.getName().getType() == 10) { 
                        Fragment f = new Fragment("field", "multiChoice");
                        final Map<String, String> options = field.getOptions();                                
                        List<String> keys = new ArrayList(options.keySet());  // bound value
                        ListMultipleChoice choice = new ListMultipleChoice("field",new PropertyModel(model, field.getName().getText()),new ArrayList(options.values()) );
                        /* new IChoiceRenderer() {
                             public Object getDisplayValue(Object o) {                          
                                 return options.get(o);
                             };
                             public String getIdValue(Object o, int i) {
                                 return o.toString();
                             };
                         });*/
                         //choice.setNullValid(true);                                      
                         choice.setLabel(new Model(field.getLabel()));                        
                         if (!field.isOptional()) {
                             choice.setRequired(true);
                         }
                         WebMarkupContainer border = new WebMarkupContainer("border");
                         f.add(border);
                         border.add(new ErrorHighlighter(choice));
                         border.add(model.bind(choice, field.getName().getText()));                    
                         listItem.add(f);       
                
                }  [/code]  
    Above code is in CustomFieldsFormPanel.java
    I am very new to Wicket . I need help fixing the problem .  Please help . I am confused with Model and ChoiceRenderer.  How should i fix this problem ?
    Please Please help me as soon as possible.
    Thanks so much
    Bharathi
    
     
  • vedbharathi ved

    vedbharathi ved - 2011-02-07

    Never Mind . I got it working.

     
  • Ashish Srivastava

    Hi Ved,
    Can you please share the version of JTrac with option to add checkbox?

    Thanks in anticipation.

    Ashish Srivastava

     
  • vedbharathi ved

    vedbharathi ved - 2012-07-19

    Sorry i didnot see this message .. Do you still need this ? let me know i will post it here. thanks

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks