jsp - jaxb marshaller object to xml -
i parse "write" xml file managed bean , view :
acceuil.xhtml:
<h:form> <p:growl></p:growl> <p:panelgrid columns="2"> <p:outputlabel value="schema name: "></p:outputlabel> <p:inputtext value="#{schemaman.schema.name_schema}" ></p:inputtext> <p:outputlabel value="description "></p:outputlabel> <p:inputtext value="#{schemaman.schema.description_schema}"></p:inputtext> <p:outputlabel value="role "></p:outputlabel> <p:inputtext value="#{schemaman.schema.defaultrole_schema}"></p:inputtext> </p:panelgrid> <p:commandbutton value="xml" action="#{schemaman.generatexml}"></p:commandbutton> </h:form> and class writexml:
public void write(schemabase sh){ schemabase shcema = new schemabase(); jaxbcontext jaxbcontext; seek { jaxbcontext = jaxbcontext.newinstance(schemabase.class); marshaller jaxbmarshaller = jaxbcontext.createmarshaller(); //specify location , name of xml file created file xmlfile = new file("c:\\espritjsf.xml"); // getting nice formatted output jaxbmarshaller.setproperty(marshaller.jaxb_formatted_output, boolean.true); // writing xml file jaxbmarshaller.marshal(shcema, xmlfile); // writing console jaxbmarshaller.marshal(shcema, system.out); } grab (jaxbexception e) { // todo auto-generated grab block e.printstacktrace(); } and managed bean :
public void generatexml(){ xl.write(schema); } and when run this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <schema/> but when create test ejb it's work don't know prb can help me plz
jsp jsf-2 jaxb
No comments:
Post a Comment