Re: [Simple-support] Problems using ElementMap
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-07-23 20:56:04
|
Hi,
The map entry element as follows:
<preselectedInterval section="OPERATION">
<timeUnit>DAY</timeUnit>
<offset>0</offset>
</preselectedInterval>
Should be:
<preselectedInterval section="OPERATION">
<timeSelection>
<timeUnit>DAY</timeUnit>
<offset>0</offset>
</timeSelection>
</preselectedInterval>
Of course you can name the timeSelection anything you like using the attribute value= in the ElementMap.
Niall
--- On Wed, 7/23/08, Hugo Schneggerich <hug...@gm...> wrote:
> From: Hugo Schneggerich <hug...@gm...>
> Subject: [Simple-support] Problems using ElementMap
> To: sim...@li...
> Date: Wednesday, July 23, 2008, 7:12 AM
> Hello,
>
> I'm trying to read some XML data using @ElementMap.
>
> Here's the XML:
>
> ...
> <time>
> <timeSelection>
>
> <maxSelectableInterval>500000</maxSelectableInterval>
>
> <defaultTimeSelectionMode>CUSTOM</defaultTimeSelectionMode>
> <preselectedIntervals>
> <preselectedInterval
> section="OPERATION">
> <timeUnit>DAY</timeUnit>
> <offset>0</offset>
> </preselectedInterval>
> <preselectedInterval
> section="DETAIL">
> <timeUnit>DAY</timeUnit>
> <offset>0</offset>
> </preselectedInterval>
> <preselectedInterval
> section="MAINTENANCE">
> <timeUnit>DAY</timeUnit>
> <offset>0</offset>
> </preselectedInterval>
> <preselectedInterval
> section="ADMIN">
> <timeUnit>DAY</timeUnit>
> <offset>0</offset>
> </preselectedInterval>
> </preselectedIntervals>
> </timeSelection>
> </time>
> ...
>
>
> Here's the Code:
>
> @Root(name = "time")
> public class Time
> {
> @Element
> public TimeSelectionEntries timeSelection;
> }
>
> public class TimeSelectionEntries
> {
> @Element
> public int maxSelectableInterval;
> @Element
> public TimeSelectionMode defaultTimeSelectionMode;
> @ElementMap(entry="preselectedInterval",
> key="section", attribute=true)
> public Map<SessionController.Sections,
> TimeSelection> preselectedIntervals;
> }
>
> public class TimeSelection
> {
> @Element
> TimeSelectionMode timeUnit;
> @Element
> int offset;
>
> // Further code not of interest here...
> }
>
> SessionController.Sections and TimeSelectionMode are
> enumerations. I tried using Strings instead of enumerations
> but also no success.
>
>
> Here's the Exception:
>
> org.simpleframework.xml.load.ValueRequiredException: Unable
> to satisfy @org.simpleframework.xml.Element(name=,
> data=false, required=true) on field 'timeUnit' for
> class ... .TimeSelection at line 125
> at
> org.simpleframework.xml.load.Composite.validate(Composite.java:389)
> at
> org.simpleframework.xml.load.Composite.readElements(Composite.java:252)
> at
> org.simpleframework.xml.load.Composite.read(Composite.java:194)
> at
> org.simpleframework.xml.load.Composite.read(Composite.java:140)
> ...
>
> I don't understand the Exception because as you can see
> the element timeUnit is definitively there. What am I doing
> wrong??
>
> Thank you!
>
> Hugo
>
>
> --
> GMX Kostenlose Spiele: Einfach online spielen und Spaß
> haben mit Pastry Passion!
> http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge
> Build the coolest Linux based applications with Moblin SDK
> & win great prizes
> Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|