I have this code:
<xe:formTable id="formTable1" formTitle="User Roles">
<xe:formRow id="formRow1" label="Category Admin">
<xe:djextNameTextBox id="edtCatAdmin" multipleSeparator="," value="#{exhibitorInfo.categoryAdmin}" />
<xe:namePicker id="namePicker1" for="edtCatAdmin">
<xe:this.dataProvider>
<xe:namePickerAggregator>
<xe:this.dataProviders>
<xe:dominoNABNamePicker addressBookSel="first" groups="false" people="true" />
<xe:dominoViewNamePicker labelColumn="mailinName" viewName="lkp_MailIn" label="Group Mailboxes" />
</xe:this.dataProviders>
</xe:namePickerAggregator>
</xe:this.dataProvider>
</xe:namePicker>
</xe:formRow>
</xe:formTable>
The goal is to just have a multi-value name picker save it's valies in a Java Bean rather then a document field. So the name picker points to a xe:djextNameTextBox to make it easy to remove the names and the xe:djextNameTextBox is bound to my bean.
Using this Java Code -
public void setCategoryAdmin(ArrayList<String> categoryAdmin) {
System.out.println("Set CategoryAdmin - List");
this.categoryAdmin = categoryAdmin;
}
public void setCategoryAdmin(String categoryAdmin) {
System.out.println("Set CategoryAdmin - String");
if (!this.isBlankString(categoryAdmin)) {
ArrayList<String> al = new ArrayList<String>();
al.add(categoryAdmin);
this.setCategoryAdmin(al);
}
}
It appears to work fine for MULTIPLE values. but if only a single valule is used I get an error: java.lang.IllegalArgumentException: argument type mismatch
I THINK this has to do with XPages returning an Array for multiple values and a String for single values. But I'm not sure how to make this work.
Any advice would be appreciated! Thanks!!
--UPDATE-- This code from the blogpost that Camac linked to seems to work.
public Object getCategoryAdmin() {
System.out.println("getCategoryAdmin");
return this.categoryAdmin;
}
@SuppressWarnings("unchecked")
public void setCategoryAdmin( Object inputMulti ) {
this.categoryAdmin = this.translateToVector( inputMulti );
}
@SuppressWarnings("unchecked")
public Vector translateToVector( Object object ){
if( object instanceof String ){
Vector list = new Vector();
list.add( object );
return list;
}
if( object instanceof List ){
return (Vector)object;
}
return null;
}
i remember having the same problem and using tips from this link helped: http://dontpanic82.blogspot.com.au/2012/06/multi-value-fields-and-beans-in-xpages.html
maybe try having the public getter and setter use java.lang.Object, instead of having 2 different ones?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With