Question

When using a drop down menu with a Java enumerate, then Stripes returns some sort of binary content rather than the actual string that should represent the enumerate.

In more details, please see how the following 2 drop down menus get converted in the SQL query:

<stripes:select name="firstDropDown" id="firstDropDown">
   <stripes:option value="">All</stripes:option>
   <stripes:option value="ITEM1">First item</stripes:option>
   <stripes:option value="ITEM2">Second item</stripes:option>
</stripes:select>

<stripes:select name="anotherEnumToChose" id="anotherEnumToChose">
   <stripes:option value="">I want them all</stripes:option>
   <stripes:options-enumeration enum="package.to.the.enumerate.AnotherEnumToChoseEnum" label="label" />
</stripes:select>

According to Stripes, I set a getLabel() Java method (for the second dropdown menu) that properly returns that enumerate as a String.

From the previous JSP, after building the SQL query, then I am getting the following where clause in the query (as an example I picket "ITEM1" from the first drop down menu, and a "ENUM1" from the second drop down menu):

and     table.first_drop_down ='SMS' 
    and     another_enum_to_chose=_binary'��\0~r\02package.to.the.enumerate.AnotherEnumToChoseEnum\0\0\0\0\0\0\0\0\0\0xr\0java.lang.Enum\0\0\0\0\0\0\0\0\0\0xpt\0ENUM1' 

I unsuccessfully commented out the <stripes:option value="">I want them all</stripes:option> as I thought it could have clashed with the <stripes:options-enumeration, but this is still not working.

On the other hand if I delete those binary settings and I use directly another_enum_to_chose = 'ENUM1' in SQL where clause then I am getting the records I am expecting from the database.

Any hint?

Was it helpful?

Solution

The issue was related to the Enumerate Java class I was using. In order to get the enumerate values I now use the name() method described in the standard documentation java.lang.Enum. Using name() now I am 100% sure I am getting a String rather than any other type/object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top