spring3mvcportlet populate JSON dojo select

大城市里の小女人 提交于 2019-12-13 03:34:46

问题


I am new to Spring mvc3 portlet and dojo. I am trying to populate select dropdown with JSON data when jsp is loaded. I want to use dojo and give ajax call to controller and return JSON when jsp is loaded. Any tips will be helpful.


回答1:


@Controller
@RequestMapping("/yourController")
public class YourController
{
  @RequestMapping(value="/combo/{id}", method=ReqestNethod.GET)
  public String getDropDownData(@ParamValue("id") long id)
  {
    List<Combo> combos = commonDao.getCombos(id);
    String json = JsonUtil.toJson(combos); // or whichever way you use
    return json;
  }
}

Send requests from dojo to this url

<your-context-path>/yourController/combo/1

where 1 is your combo id.

I haven't checked the syntax here.. Wrote it blind. You might get compilation errors.




回答2:


I get data in below format How do I populate dojoType="xwt.widget.form.FilteringSelect" {"ValuesDTO": {"items": [{},{"default": {"size": 5},"int": 10,"string": "Product1","string": "Product1 ","string": "product3","string": "product4","string": "product5"}]}}

I am sending dat in bean--->DTO--->List



来源:https://stackoverflow.com/questions/10781112/spring3mvcportlet-populate-json-dojo-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!