Hello all,
I was able to validate simple input elements like textfield but could not
validate optiontransferselect element. Actually i want to show the
validation error when the selected list is empty. the code snippet is shown
below:
<s:optiontransferselect
label="Levels of Sequence"
name="levels"
leftTitle="Available Levels:"
rightTitle="Selected Levels:"
list="availableLevelsList"
listKey="id"
listValue="level_name"
doubleName="selectedLevels"
doubleList="selectedLevelsList" doubleListKey="id"
doubleListValue="level_name" theme="css_xhtml" required="true"/>
The code snippet of the corresponding action class is:
private List<HierarchyLevel> availableLevelsList = new
ArrayList<HierarchyLevel>();
private List<HierarchyLevel> selectedLevelsList = new
ArrayList<HierarchyLevel>();
private List<Long> selectedLevels = new ArrayList<Long>();
public List<HierarchyLevel> getAvailableLevelsList() {
return availableLevelsList;
}
public void setAvailableLevelsList(List<HierarchyLevel>
availableLevelsList) {
this.availableLevelsList = availableLevelsList;
}
public List<HierarchyLevel> getSelectedLevelsList() {
return selectedLevelsList;
}
public void setSelectedLevelsList(List<HierarchyLevel>
selectedLevelsList) {
this.selectedLevelsList = selectedLevelsList;
}
public List<Long> getSelectedLevels() {
return selectedLevels;
}
@RequiredFieldValidator(key="sequence.selectedLevelsNotEmpty", message =
"one or more levels must be selected")
public void setSelectedLevels(List<Long> selectedLevels) {
this.selectedLevels = selectedLevels;
}
As i have to validate the right select element of the optiontransferselect
so i used the setter property of the selectedLevels.
Hope i am missing something as upon submit no validation error is thrown.
--
Thanks,
Prashant Khanal
[EMAIL PROTECTED]
Solutions for your information
_________________
Yomari Pvt. Ltd.
HB Complex, Ekantakuna, Lalitpur.
G.P.O. Box: 21295
Kathmandu, Nepal
Tel: 977 (1) 5000111, 2113000
Fax: 977 (1) 5000157
http://www.yomari.com
____________________
Your guide to Nepal on the Net.
http://www.nepalhomepage.com