You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexander Landsnes Keül <Al...@visma.no> on 2007/12/18 12:39:22 UTC

ListView TextFields return null

Hi,

 

I'm trying to get some input setup in a listview, seeing as I cannot know how many input fields there will be, or the type. The issue I'm getting is that the input is always null, not whatever I jot into the box. I've setReuseProperty(true), but that didn't solve the issue.

 

When I submit, which is done from a modalwindow, I get a null pointer exception on the rerender of the panel containing the information. I can't for the life of me understand what causes the problem, a few creative breakpoints show it as setting null all over the line.

 

Alexander

 

The code is as follows

 

            final Form form = new Form("form", new CompoundPropertyModel(line));

            form.setOutputMarkupId(true);

            add(form);

 

            ListView listview = new PropertyListView("elements", elements) {

                  private static final long serialVersionUID = 1L;

                  int count = 0;

 

                  @Override

                  public void populateItem( final ListItem item ) {

                        final CvElement<?> element = (CvElement<?>) item.getModelObject();

                        item.add(new Label("label", labels.get(count)));

 

                        if (element.getType() == ElementType.PRIMITIVE)

                             item.add(new PrimitivePanel("input", element));

 

                        if (element.getType() == ElementType.LIST)

                             item.add(new DropDownPanel("input", element));

 

                        if (element.getType() == ElementType.DOUBLELIST)

                             ;

 

                        count++;

                  }

            };

 

            form.add(listview.setReuseItems(true));

 

The only panel I'm currently testing on is the PrimitivePanel, which has the following code:

 

public class PrimitivePanel extends BasePanel {

      private static final long serialVersionUID = 1L;

 

      public PrimitivePanel ( final String id, final CvElement<?> element ) {

            super(id);

 

            final FormComponent fc = new TextField("value.value");

            fc.setRequired(element.isRequired());

            add(fc);

      }

}


Re: ListView TextFields return null

Posted by Igor Vaynberg <ig...@gmail.com>.
the way you are using compound model....every textfield is writing
into the same property - so no matter how many you have you will only
keep the input of the last one processed. you need a model that can
properly populate a list...makes sense?

-igor


On Dec 18, 2007 3:39 AM, Alexander Landsnes Keül
<Al...@visma.no> wrote:
> Hi,
>
>
>
> I'm trying to get some input setup in a listview, seeing as I cannot know how many input fields there will be, or the type. The issue I'm getting is that the input is always null, not whatever I jot into the box. I've setReuseProperty(true), but that didn't solve the issue.
>
>
>
> When I submit, which is done from a modalwindow, I get a null pointer exception on the rerender of the panel containing the information. I can't for the life of me understand what causes the problem, a few creative breakpoints show it as setting null all over the line.
>
>
>
> Alexander
>
>
>
> The code is as follows
>
>
>
>             final Form form = new Form("form", new CompoundPropertyModel(line));
>
>             form.setOutputMarkupId(true);
>
>             add(form);
>
>
>
>             ListView listview = new PropertyListView("elements", elements) {
>
>                   private static final long serialVersionUID = 1L;
>
>                   int count = 0;
>
>
>
>                   @Override
>
>                   public void populateItem( final ListItem item ) {
>
>                         final CvElement<?> element = (CvElement<?>) item.getModelObject();
>
>                         item.add(new Label("label", labels.get(count)));
>
>
>
>                         if (element.getType() == ElementType.PRIMITIVE)
>
>                              item.add(new PrimitivePanel("input", element));
>
>
>
>                         if (element.getType() == ElementType.LIST)
>
>                              item.add(new DropDownPanel("input", element));
>
>
>
>                         if (element.getType() == ElementType.DOUBLELIST)
>
>                              ;
>
>
>
>                         count++;
>
>                   }
>
>             };
>
>
>
>             form.add(listview.setReuseItems(true));
>
>
>
> The only panel I'm currently testing on is the PrimitivePanel, which has the following code:
>
>
>
> public class PrimitivePanel extends BasePanel {
>
>       private static final long serialVersionUID = 1L;
>
>
>
>       public PrimitivePanel ( final String id, final CvElement<?> element ) {
>
>             super(id);
>
>
>
>             final FormComponent fc = new TextField("value.value");
>
>             fc.setRequired(element.isRequired());
>
>             add(fc);
>
>       }
>
> }
>
>

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