【问题标题】:how to trigger ajax update with radio button in Tapestry 4.0?如何在 Tapestry 4.0 中使用单选按钮触发 ajax 更新?
【发布时间】:2013-06-21 07:31:48
【问题描述】:

下面有两个单选按钮(值 A 或 B)和调色板区域。我想在选择值 A 时显示调色板,并在选择 B 时隐藏它,所以 ajax 更新。 怎么做? 我正在为现有项目使用旧的 Tapestry 4.0.2,所以我无法升级。

这是我目前的代码

标记:

<span jwcid="models@RadioGroup" selected="ognl:modelOption">
   <tr>
       <td class="dataLabel" width="15%">
       </td> 

       <td>    
           <input type="radio" jwcid="@Radio" value="ognl:@com.example.MyPage@ALL"/> All models (Default)
       </td>        

   </tr>

   <tr>
       <td class="dataLabel" width="15%">
       </td> 

       <td> 
           <input type="radio" jwcid="@Radio" value="ognl:@com.example.MyPage@SPECIFIC"/> Specific models
       </td>

   </tr>       
</span>

<span jwcid="@If" condition="ognl:specificDeviceModels">
   <tr>
       <td class="dataLabel" width="15%">
          <span key="supportedDeviceModelsLabel">Supported device models:</span>:
       </td>

       <td>
           <div class="bundle_palette">
              <span jwcid="palette"/>
           </div>
       </td>
   </tr>
</span>

Java:

public static final Integer ALL = new Integer(1);
public static final Integer SPECIFIC = new Integer(2);

public abstract Integer getModelOption();

public abstract List<DeviceModel> getSelectedDeviceModels();
public abstract void setSelectedDeviceModels(List<DeviceModel> deviceModels);

public abstract void setDeviceModels(List<DeviceModel> deviceModels);
public abstract List<DeviceModel> getDeviceModels();

@Component(type = "contrib:Palette", bindings = {"selected=selectedDeviceModels", "model=deviceModel"})
public abstract Palette getPalette();

 public IPropertySelectionModel getDeviceModel() {
    return new OptionValueSelectionModel(getDeviceModels()).sorted();
}

public void pageBeginRender(PageEvent event) {

    setDeviceModels(getDeviceService().findDeviceModels(null));
}

public boolean getSpecificDeviceModels() {
    //here I need to set boolean value and return it 
   return true/false;
}

【问题讨论】:

    标签: java ajax radio-button tapestry


    【解决方案1】:

    作为旧版 Tapestry 的解决方案,我不得不使用 tacos 库:

    http://tacos.sourceforge.net/components/tapestry/RadioGroup.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-25
      • 2011-12-24
      • 1970-01-01
      • 2012-07-18
      • 1970-01-01
      • 2011-03-17
      • 1970-01-01
      • 2018-03-15
      相关资源
      最近更新 更多