On 08/31/2011 10:50 AM, Karel Gardas wrote:
Hello,
is there any example which shows usage of DBStringList property together
with support for selecting multiple values of this property (by for
example using checkboxes) and also showing how such values are later
obtained from the property?
I'm asking since I'm not sure if property is able to kind of change into
property list (probably) and also I'm fighting with this and I'm still
not able to obtain more than one value from returned property object.
Hi Karel,
Yes, this is supported and it's something quite fundamental, so it
should work very well.
Open the class editor and add a new property of type Database List.
Write the query you want to use to extract the possible values for that
property from the database.
Make sure you select the Multiple Select and Relational Storage
checkboxes. Multiple Select allows you to select and store multiple
values from the list, while Relational Storage makes it easier to
integrate that property into other queries by storing each selected item
in its own entry in the database (without it all the selected values are
stored in one row, concatenated into a VARCHAR column), and to store
more than a few selected values (since the column allows at most 255
characters in total).
Change the Display Type select to what you want. Checkbox is one of the
possible values. If you leave it to Select, also increase the value of
the "Size of the corresponding form element in edit mode" option.
Now, when you display the field in edit mode it should appear as a list
of checkboxes.
To get the selected values, you mustn't use the display() or get()
methods, since those are for generating HTML, and not for accessing the
raw value of the property. Use something like this:
$doc.getObject('Your.Class').getProperty('propertyName').values
This should return an ArrayList with all the selected values.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/