Spring.AjaxEventDecoration を使用して JSP にドロップダウンを動的に設定していますが、元のモデルにバインドできないため、エラーがスローされています。私はこれをしばらく研究してきましたが、これが可能だとは思いませんが、そうあるべきだと思われるため、この投稿..誰か助けてください!
OK 私のコントローラは、このように見えます。
@Controller
@RequestMapping(value = "/cis/crimeProperty/")
public class CrimePropertyController
{
@RequestMapping(value = "/manageView", method = RequestMethod.GET)
public ModelAndView managePropertyDetails(Long propertyId) throws DAOException
{
Map<String, Object> model = new HashMap<String, Object>();
CrimePropertyVO crimePropertyVO = new CrimePropertyVO();
model.put("crimePropertyVO", crimePropertyVO);
return new ModelAndView("cis.crime.property.edit", model);
}
@RequestMapping(value = "/changeItemList", method = RequestMethod.POST)
public ModelAndView retrieveItemList(String propertyClass)
{
Map<String, Object> model = new HashMap<String, Object>();
..call service to get list of items from class..
model.put("propertyItemList", propertyItemList);
return new ModelAndView("/cis/property/crime_property_item", model);
}
}
私はタイルを使用しているので、タイルの定義は次のようになります。
<definition name="cis.crime.property.edit" template="/WEB-INF/jsp/cis/property/manage_crime_property.jsp">
<put-attribute name="itemListFrag" value="/WEB-INF/jsp/cis/property/crime_property_item.jsp"/>
私の (manage_crime_property.jsp) JSP は次のようになります。
<form id= "changeList" action="${pageContext.request.contextPath}/smvc/cis/crimeProperty/changeItemList" method="post">
<select id="propertyClassChange" path="propertyClass">
<option value="" label="-Please Select-"/>
<option value="CLO" label="CLOTHING"/>
<option value="TOL" label="TOOLS"/>
</select>
</form
<form:form modelAttribute="crimePropertyVO" action="${pageContext.request.contextPath}/smvc/cis/crimeProperty/saveProperty" method="post">
<table class="genericOutlinedTable" style="width: 100%;">
<tr>
<td><b>Item</b></td>
<td>
<tiles:insertAttribute name="itemListFrag" flush="true" ignore="false"/>
</td>
</tr>
<tr>
<td><b>Make</b></td>
<td><form:input path="propertyMake" size="20" maxlength="20"/></td>
<td><b>Model</b></td>
<td><form:input path="propertyModel" size="15" maxlength="15"/></td>
</tr>
</form:form>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({ elementId:'propertyClassChange', event:'onchange', formId:'changeList', params: {fragments: 'itemListFrag'} }));
My (crime_property_item.jsp) JSP fragment looks like this,
<span id="itemListFrag">
<form:select path="propertyItem">
<form:option value="" label="-Please Select-">
<c:forEach var="itemList" items="${propertyItemList}">
<form:option value="${itemList.propertyCode}" label="${itemList.propertyCode}" />
</c:forEach>
</form:select>
</span>
すべて正しく構成されており、最初のドロップダウンを変更すると、コントローラーの changeItemList メソッドが呼び出され、オプションを構成するために JSP フラグと項目のリストが返されますが、サーバー エラーが発生します ... BindingResult も、Bean 名のプレーン ターゲット オブジェクトもありませんフラグに options タグだけを入れようとしましたが、うまくいきません。spring:bind タグと通常の選択を使用しようとしましたが、どちらも機能しません。
これについて何か助けてくれてありがとう。