0

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.

sigi
  • 189
  • 3
  • 9

2 Answers2

1

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

Community
  • 1
  • 1
Jigar Parekh
  • 6,163
  • 7
  • 44
  • 64
0

Thank you very much! For newcomers: use it in jspx like this:

 items="${applicationScope.StatusList}"

implement servletContextAware in the class.

Save the list to servletcontext. (setServletContext method)

I couldnt find solution for itemvalue to be working, any way to get field:select without being editable? (So a drop down list, without edit)?

sigi
  • 189
  • 3
  • 9