Jacques, It would help if you could submit a Jira issue along with a patch that recreates the problem. There isn't enough information in your email to track the problem down.
-Adrian --- On Sun, 7/4/10, Jacques Le Roux <jacques.le.r...@les7arts.com> wrote: > From: Jacques Le Roux <jacques.le.r...@les7arts.com> > Subject: Weird error in form widget > To: dev@ofbiz.apache.org > Date: Sunday, July 4, 2010, 8:35 AM > Hi, > > In a custom project I have got a weird error in form > widget. > When I set a field in the actions part using > something like > > <set field="findInventoryView" > from-field="findInventoryViewList[0]"/> > > and use findInventoryView as default map for the form, I > get this error > > java.lang.ClassCastException: > java.lang.String cannot be cast to java.util.Map > (java.lang.String cannot be cast to java.util.Map) > > This issue comes from the line: ModelForm.java[1834] > (current revision), ie: > > public Map<String, ? extends > Object> getDefaultMap(Map<String, ? extends Object> > context) { > return > this.defaultMapName.get(context); > } > > The problem in this case is that it returns a String and a > Map is expected. There are at least 3 possible workarounds: > 1. Put the actions snippet in the screen > 2. User rather map-name="findInventoryViewList[0]" when > addressing form's fields (using > map-name="findInventoryViewList" does not > work > 3. Use <set field="findInventoryView" > from-field="findInventoryViewList[0]" type="Object"/> > > To check if it could be due to recent OFBiz changes, I > "reverted" (svn up to previous OFBiz revisons) 1st some > recent potential > culprits but got nothing. To be sure I updated to 1st May, > still nothing new. Then I tried to update to 1st April (not > a joke ;o) > and then got compliation issues in the custom app and gave > up. > > At this stage, I simply don't understand why > FindInventoryView instance are Strings in the context, when > retrieved in the form, and > correct Maps when retrieved in the screen (I guess, I did > not check in screen but it works) . > There is obviously a low level bug somewhere but it's not > something new. It seems related to context population code, > not sure > though. > > I can use one of the workarounds and it's not blocking. But > I really find weird to have to put type="Object" to get this > line to > work! > > Has anybody an idea of what could have caused this issue? > Maybe also this issue exists for a long time and I just > discovered it, > since I did not try to "revert" before 1s May. > > One last thing to note is that in my case > findInventoryViewList is always a list with a sole entry. So > maybe it's the reason, > something put a String in the Context when it should put a > Map. > > I prefer to ask than simply to use a workaround, because > maybe it's a regression and more is hidden behind... > > Thanks > > Jacques > > >