Search code examples
springspring-mvcspring-roo

field:select with a static List in Spring Roo


Hy everyone.

I have a simple problem here. in my order class i have OrderStatus field, which is an enum in the database. (Can be "Under process" or Dispatched)

My problem is when im using update.jspx i want a field:select dropdown list, where the admin can change this value.

Because these values can not be read out from database, i was thinking of creating a static arraylist inside order.java like this:

public static List<String> StatusList;
static{
  ArrayList<String> tmp = new ArrayList<String>();
  tmp.add("Under process");
  tmp.add("Dispatched");
  StatusList = Collections.unmodifiableList(tmp);
}


public List<String> getStatusList() {
    return StatusList;
}

How can i read out these value using field:select tag, and set them as orderStatus?

<field:select field="orderStatus" id="c_photostore_Porder_orderStatus" items="${porders}" itemValue="orderStatusList" path="/porders"/>

if i could call a method from update.jspx would be fine also i think, but i know the syntax only in webflow, not in standard roo.


Solution

  • You can place the List in a ServletContext or request attribute and access it on the jsp by calling ${application.StatusList} or ${request.StatusList}.

    you can also apply solution described in post