Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

java - Using "Simple" XML Serialization to load data from res/raw on Android -


i new java , android development, please keep in mind. goal deserialize data xml files packaged application. i'm attempting using simple 2.4 "unhandled exception type exception" error in code when using .read or .write

my code looks this:

import java.io.inputstream;  import android.app.activity; import android.os.bundle; import android.view.view;  import org.simpleframework.xml.serializer; import org.simpleframework.xml.core.persister;  public class ftroster extends activity {     /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);          //load in available ship files here     }      public void myclickhandler(view view)     {       inputstream istream = getresources().openrawresource(r.raw.ship);      serializer serializer = new persister();      shipsystem newsystem = serializer.read(shipsystem.class, istream);   } } 

and class looks this:

import org.simpleframework.xml.element; import org.simpleframework.xml.root;  @root public class shipsystem {  @element  public string id = null;   @element  public boolean destroyed = false;   @element  public int systemvalue = 0;  } 

if put try / catch around it, of course error goes away, deserilization never occurs well. there little discussion on simple , documentation makes simple c# serialization. appreciated on problem.

a global view of i'm wanting have xml file each "shipsystem" , @ boot of application deserialize each 1 it's own class instance , have of these available in array lookup.

thanks taking time read , think this.

i've changed myclickhandler follows validate xml first:

public void myclickhandler(view view) {     inputstream istream = getresources().openrawresource(r.raw.system);     serializer serializer = new persister();      if(serializer.validate(shipsystem.class, istream))     {         shipsystem newsystem = serializer.read(shipsystem.class, istream);     }            } 

i've changed class appear this:

import org.simpleframework.xml.attribute; import org.simpleframework.xml.element; import org.simpleframework.xml.root;  @root(name="system") public class shipsystem {     @attribute     public string id = "0";      @element     public boolean destroyed = false;      @element     public int systemvalue = 0;  } 

and xml i'm attempting deserialize looks this:

<?xml version="1.0" encoding="utf-8"?> <system id="0">     <destroyed>false</destroyed>     <systemvalue>0</systemvalue> </system> 

it seems method used serializer causes unhandled exception of type exception because use of serializer.validate causes same problem. missing required simplexml?


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -