Quantcast
Channel: Adobe Community : Popular Discussions - LiveCycle Workbench
Viewing all articles
Browse latest Browse all 69588

Component that returns portions or full xml for a form

$
0
0

Hi all,

I have created a component with differents functions to return a string variable that contains a portion or a full xml, wich will be binded to a xdp form.

When I try to inject the xml, using deserialize(string), is full of < > and other caracters and I can get the binding well inside the form when I render in workspace.

What should I do this to get this work?

Here is one funcion I have in my component, wich get some data from a database and then construct a DOM XML document and converted to a string...

 

public java.lang.String getConvenios(int region){
        try
        {
            Class.forName("XXXXXXXXXXXXXXXX");
            Connection dbConnection = DriverManager.getConnection("XXXXXXXXXXX",user, password);
            PreparedStatement sqlStatement;
           
           
            DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance();
            //get an instance of builder
            DocumentBuilder db = dbf.newDocumentBuilder();
            //create an instance of DOM
            Document dom = db.newDocument();
            Element root=dom.createElement("process");
            dom.appendChild(root);
            Element fechaActual=dom.createElement("date1");
            raiz.appendChild(date1);
            Element cblist=dom.createElement("cblist");
            raiz.appendChild(cblist);
            Text textVar;

            //cb will be mapped to a drop down list
            Element conSelec=dom.createElement("conSelec");
            cblist.appendChild(conSelec);
           
            String query="XXXXXXXXXXX";
            sqlStatement= dbConnection.prepareStatement(query);
            ResultSet rs = sqlStatement.executeQuery();
            while(rs.next())
            {
                Element item=dom.createElement("item");
                convenioSeleccionado.appendChild(item);
               
                Element nameCon=dom.createElement("nameCon");
                item.appendChild(nameCon);
                textVar=dom.createTextNode("Con N°: "+rs.getInt(1)+" - "+rs.getString(2));
                nombreConvenio.appendChild(texto);
               
                Element idCon=dom.createElement("idCon");
                item.appendChild(idConvenio);
                textVar=dom.createTextNode(""+rs.getInt(1));
                idConvenio.appendChild(texto);
            }           
            if(!sqlStatement.isClosed())
                sqlStatement.close();
            if(!dbConnection.isClosed())
                dbConnection.close();
           
           
                    /////////////////
            //Output the XML

 

            //set up a transformer
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");

 

            //create string from xml tree
            StringWriter sw = new StringWriter();
            StreamResult result = new StreamResult(sw);
            DOMSource source = new DOMSource(dom);
            trans.transform(source, result);
            String xmlString = sw.toString();
                       
            return xmlString;
        }
        catch(Exception e)
        {
            return "ERROR: "+e.getMessage();
        }       
    }

 

 

Any help will be appretiated...


Viewing all articles
Browse latest Browse all 69588

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>