Apache Wicket:试图在null对象上设置属性值.属性表达式:metaCarrier值:SearchFormS



我正在尝试使用以下代码。

我遇到错误
试图在null对象上设置属性值。属性表达式:metaCarrier值:SearchFormSelectOption[key=367,Value=KPN]

在Ajax调用

知道可能出了什么问题吗?,

代码如下

   final DropDownChoice<SearchFormSelectOption> metaCarrier = new DropDownChoice<SearchFormSelectOption>("metaCarrier", carrierChoices, new ChoiceRenderer<SearchFormSelectOption>("value")
        {
           @Override
           public Object getDisplayValue(SearchFormSelectOption option)
           {
              LOG.error("check display object ....." + option.getValue());
              return option.getValue();
           }
           @Override
           public String getIdValue(SearchFormSelectOption option, int index)
           {
              return option.getKey();
           }
        });
     metaCarrier.setNullValid(true);
     metaCarrier.setOutputMarkupId(true);
     ruleCreationListView.add(metaCarrier);  
     metaCarrier.add(new AjaxFormComponentUpdatingBehavior("onchange")
        {
           /**
            * 
            */
           private static final long serialVersionUID = 1L;
           @Override
           protected void onUpdate(AjaxRequestTarget target)
           { 
           LOG.info("Carrier===============" + (getModelObject()).getMetaComSelectCarrier());
     }});


 public class SearchFormSelectOption implements Serializable
 {
   /** The Constant serialVersionUID. */
   private static final long serialVersionUID = 1L;
    /** The key. */
   private String key;
    /** The value. */
    private String value;
   //getter and setters

请直接从自定义选项显示中查看以下示例代码。在此处查找更多样本。

public class SelectOption {
    private String key;
    private String value;
    public SelectOption(String key, String value) {
      this.key = key;
      this.value = value;
    }
  //...[getters and setters]...
  }
//create an instance of DropDownChoice with appropriate ChoiceRenderer.
 SelectOption[] options = new SelectOption[] { new SelectOption("&", "AND"),
            new SelectOption("|", "OR") };
 ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key");
 DropDownChoice dropDownChoice = new DropDownChoice("connective", model, Arrays.asList(options), choiceRenderer);

相关内容

  • 没有找到相关文章