Edit: This issue appears to be isolated to Firefox - in Chrome/IE it works exactly as expected. Is this a Firefox bug, or just something I'm not understanding?
I have a spring form. The form contains, among other things, a <select>
element- which is bound to a corresponding element in the ModelMap using a 'path' property in the JSP.
However, the <select>
element's apparent value does not update on soft page refresh, even if the value in the model-map changes. Other references to the model value do update (e.g. if I just add ${MyModelMapValue } - then the value will update on soft refresh - so no caching or anything is taking place).
After hard refresh (CTRL+F5) the select updates. How can I update the select on soft refresh?
Use Case:
I browse to the page for the first time, I see the correct values bound correctly to the form fields - including my
<select>
element - which is bound to an element in the model map, say: MyModelMapValue = 'ordered'In the background (say, someone elses's browser) while I have the page open in my browser, the value of MyModelMapValue changes, and persists that change to the DB. MyModelMapValue = 'shipped'
Initially the values don't change in my tab - which I would expect, as the values are not continuously updated from the DB.
Now I hit F5 in my browser.
I can see a normal GET call is generated, and hits my controller, the new model is correctly generated (With MyModelMapValue = 'shipped') and is served alongside the view to the browser.
All other references to the model value (e.g. ${MyModelMapValue} will show as 'shipped'
the
<select>
element is still bound to MyModelMapValue, but shows 'ordered' as it's value.
Question:
Is this the way Spring Forms binding is supposed to work, or am I doing something wrong?
Code:
Spring Form JSP definition:<form:form commandName="productHolder" id="productForm" method="post">
<form:input path="product.blah" placeholder="blah" class="blah-blah" />
<br>
... a bunch of other fields ...
<br>
Supplier Status:
<form:select path="product.supplierStatusObjectFromListOfStatusObjects.currentSatus">
<form:options items="${allProductSupplierStatuses}"/>
</form:select>
<br>
Printing the value as a test: ${product.getSupplierStatusFromListOfStatusObjects.currentSatus}
<br>
<button class="btn btn-success" type="submit">Save</button>
</form:form>
Stripped back Java Controller:
@RequestMapping(method=RequestMethod.GET)
public String showProductStatusScreen(ModelMap model, @RequestParam(value = "productId", required=false) Long productId){
this.checkAccess(this.getCaller());
Product product = productBusinessObject.getProductById(productId);
ProductHolder productHolder = this.generateProductHolder(product);
model.put("productHolder", productHolder);
//printing it out as a test:
System.out.println(productHolder.GetProduct.getSupplierStatusObjectFromListOfStatusObjects.getCurrentSatus);// <- Prints out the correct value
return "/WEB-INF/jsp/productStatusScreen.jsp";
}