我有dojo filteringSelect和dojo组合框组件的问题。我试过使用这两个组件,但问题是一样的。我意识到转换器永远不会被调用,并且当组合框填充值时,我收到错误 java.lang.IllegalArgumentException:参数类型不匹配。
<xe:djFilteringSelect id="cbDocumentCategoryListtt"
dojoType="dijit.form.ComboBox"
value="#{compositeData.archiveDocument.documentCategory}"
disabled="#{javascript:!compositeData.editMode}">
<xe:this.queryExpr><![CDATA[${javascript:"*$\{0}*"}]]></xe:this.queryExpr>
<xe:this.converter>
<xp:converter
converterId="ConverterDocumentCategory">
</xp:converter>
</xe:this.converter>
<xp:selectItems id="selectItems2">
<xe:this.value><![CDATA[#{javascript:try{
ControllerDocumentCategory.getAllDocumentCategoryBasedOnLRM(compositeData.archiveDocument.entryDateFrom,compositeData.archiveDocument.entryDateUntil,compositeData.archiveDocument.fund,true)
}
catch(e)
{
var msg="Error: "+ e.toString()+" See log.";
var msgObj = new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, msg, msg);
facesContext.addMessage("",msgObj);
log.logError( e.toString(), null, e ,123,"ccArchiveDocumentBase.xsp",msg);
}}]]></xe:this.value>
</xp:selectItems>
</xe:djFilteringSelect>
这是转换器
public class ConverterDocumentCategory implements Converter{
@Override
public Object getAsObject(FacesContext context, UIComponent uiComponent, String text) {
try
{
if (text == null || text.isEmpty())
{
return null;
}
String msg=LanguageManager.getInstance().getMessageFromPropFile("_object_converter_not_found","WEB-INF/langMsg.properties");
String [] all=text.split(" - ");
String name=all[0];
String codeText=all[1];
DocumentCategory documentCategory=new DocumentCategory();
documentCategory.setCodeText(codeText);
documentCategory.setName(name);
documentCategory.setActive("");
List list=DbLotusBroker.getInstance().ftSearch(documentCategory,true);
if(list.size()==0 || list.get(0)==null)
{
FacesContext.getCurrentInstance().getCurrentInstance().addMessage("", new FacesMessage(msg));
throw new Exception(msg);
}
documentCategory=(DocumentCategory) list.get(0);
return documentCategory;
}
catch (Exception e) {
SRCLogFactory.getInstance().getLog().logError(e);
context.addMessage("", new FacesMessage("Greška:" +e));
}
return null;
}
@Override
public String getAsString(FacesContext context, UIComponent uiComponent, Object obj) {
DocumentCategory documentCategory=(DocumentCategory) obj;
return documentCategory.getName()+" - "+documentCategory.getCodeText();
}
}
在这个方法中,我为过滤选择准备列表:
public List<SelectItem> getAllDocumentCategoryBasedOnLRM(Object objFrom, Object objUntil, Object objFund,boolean active) {
sig=new ArrayList<SelectItem>();
sigActive=new ArrayList<SelectItem>();
FacesContext context=FacesContext.getCurrentInstance();
try
{
if(objFrom==null || objFund == null || objUntil==null || ((Fund)objFund).getCodeText()==null || ((Fund)objFund).getCodeText().equals(""))
{
return sig;
}
Fund fund=(Fund) objFund;
Date date=(Date) objFrom;
Calendar cal=Calendar.getInstance();
cal.setTime(date);
if(fund.getCodeText().equals("3")){
LRM lrmm= new LRM();
lrmm.setCurrent("1");
lrmm.setFund(fund);
lrmm=(LRM) DbLotusBroker.getInstance().ftSearch(lrmm, true).get(0);
if(cal.after(lrmm.getDateFrom()) || cal.equals(lrmm.getDateFrom()))
{
DocumentCategory dc=new DocumentCategory();
LRMGroup lrmGroup = new LRMGroup();
lrmGroup.setLrm(lrmm);
dc.setLrmGroup(lrmGroup);
dc.setActive("1");
List<Object>list=DbLotusBroker.getInstance().ftSearch(dc, true);
sig.add(new SelectItem(new DocumentCategory()));
sigActive.add(new SelectItem(new DocumentCategory()));
for (Object object : list)
{
DocumentCategory documentCategory=(DocumentCategory) object;
sig.add(new SelectItem(documentCategory));
if(documentCategory.getActive().equals("1"))
sigActive.add(new SelectItem(documentCategory));
}
}else{
getLrmCategory(objFrom, objUntil, objFund, active);
}
}
else{
getLrmCategory(objFrom, objUntil, objFund, active);
}
}
catch (Exception e) {
SRCLogFactory.getInstance().getLog().logError(e);
context.addMessage("", new FacesMessage("Greška "+e));
}
if(active)
return sigActive;
else
return sig;
}
Converter在faces-config.xml文件中注册:
<description>A Converter for document category</description>
<converter-id>ConverterDocumentCategory</converter-id>
<converter-class>com.src.converters.ConverterDocumentCategory</converter-class>
</converter>
我认为这个问题是由使用扩展库xe:djFilteringSelect中的组件引起的,也许这个组件不能与Converter一起使用。有什么想法吗?