Topic
  • 2 replies
  • Latest Post - ‏2012-01-15T11:29:34Z by P0UM_Himanshu_Saxena
SystemAdmin
SystemAdmin
265 Posts

Pinned topic Problem sending data from servlet to xfroms

‏2008-07-31T16:53:30Z |
Hi,
First of all thanks for the time spent reading this.
I've recently started with my first xfroms project. I'm familiar with jsp and servlets so I started with the login xform and the servlet that has the business logic of the autentication process.
When I submit info from the xform to the servlet everuthing works fine but.... the problem is that when the servlet finishes I'm not sure what is thw best way to send that data to the xforms.
I've tried to load it from a file and from the servlet itself but nothing works.

This is the conectar.jsp page:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<% response.setContentType("application/xhtml+xml"); %>
<xhtml:html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xhtml:head>
<xhtml:title>Conexión</xhtml:title>
<xforms:model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xforms:instance id="datos_enviados">
<datos_formulario>
<origen>CONEXION</origen>
<orden/>
<parametros>
<usuario/>
<clave/>
</parametros>
</datos_formulario>
</xforms:instance>

<xforms:submission action="http://localhost:8080/proyecto/Controlador" id="Conectar" method="post" ref="/datos_formulario" encoding="ISO-8859-1" replace="all">
<xforms:action ev:event="xforms-submit">
<xforms:setvalue ref="instance('datos_enviados')/orden">CONECTAR</xforms:setvalue>
</xforms:action>
</xforms:submission>

<xforms:instance id="datos_recibidos" src="<%=session.getAttribute("resultado") %>">
<datos_resultado></datos_resultado>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body>
<xhtml:div id="formulario">
Esta es la página <xforms:output ref="instance('datos_enviados')/origen"/>
<xforms:input ref="instance('datos_enviados')/parametros/usuario">
<xforms:label>Usuario</xforms:label>
</xforms:input>
<xforms:secret ref="instance('datos_enviados')/parametros/clave">
<xforms:label>Clave</xforms:label>
</xforms:secret>
<xforms:submit submission="Conectar">
<xforms:label>Conectar</xforms:label>
</xforms:submit>
</xhtml:div>

<xhtml:div id="mensaje">
<xforms:output ref="instance('datos_recibidos')/mensaje"/>
</xhtml:div>

</xhtml:body>
</xhtml:html>

if everithig is ok the serlet calls for the page bellow, else it calss for the first one and show a message.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<% response.setContentType("application/xhtml+xml"); %>
<xhtml:html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xhtml:head>
<xhtml:title>Principal</xhtml:title>
<xforms:model id="datos_a_enviar">
<xforms:instance xmlns="">
<datos_formulario>
<origen>PRINCIPAL</origen>
<orden/>
<parametros/>
</datos_formulario>
</xforms:instance>
<xforms:bind id="ori" nodeset="/datos_formulario/origen"/>
<xforms:submission action="http://localhost:8080/proyecto/Controlador" id="Ordenar" method="post" ref="/datos_formulario"/>
</xforms:model>

<xforms:model id="datos_recibidos">
<xforms:instance xmlns="" src="<%=session.getAttribute("resultado") %>">
<datos_resultado>
<resultado></resultado>
<destino></destino>
<usuario></usuario>
<nombreusuario></nombreusuario>
<perfil></perfil>
</datos_resultado>
</xforms:instance>
<xforms:bind id="nombre" nodeset="/datos_resultado/nombreusuario"/>
<xforms:bind id="perfilado" nodeset="/datos_resultado/perfil"/>
</xforms:model>
</xhtml:head>

<xhtml:body>
<xforms:group model="datos_recibidos">
<xhtml:h1>Este es el menú principal de </xhtml:h1><xforms:output bind="nombre"/>
<xhtml:h1>que tiene un perfil de </xhtml:h1><xforms:output bind="perfilado"/>
</xforms:group>
<xhtml:h1> Cargado desde <%=session.getAttribute("resultado") %></xhtml:h1>
<xhtml:h1> Cargado en <xforms:output bind="ori"/></xhtml:h1>

</xhtml:body>
</xhtml:html>

I dindn't get the first page to show the conection errors when they existed so I try to load the xml file directly from the server but I'm not sure how to atach XML data to the response or the way the servlet can populate an instance of the xform.

Thank you very much for your atention and sorry for the long, long post.

Thnaks,

Xabier
Updated on 2012-01-15T11:29:34Z at 2012-01-15T11:29:34Z by P0UM_Himanshu_Saxena
  • SystemAdmin
    SystemAdmin
    265 Posts

    Re: Problem sending data from servlet to xfroms

    ‏2008-07-31T16:58:59Z  
    Sorry, when I said in the first post that I tried to load the xml data from the server I mean I tried to load it from the response buid up by the servlet.

    if the conection is ok the file is like

    <datos_resultado>
    <resultado>CORRECTO</resultado>
    <destino>principal.jsp</destino>
    <usuario>xlareo</usuario>
    <nombreusuario>Xabier</nombreusuario>
    <perfil>ADMINISTRADOR</perfil>
    </datos_resultado>

    if theres is any problem it is like this

    <datos_resultado>
    <resultado>ERROR</resultado>
    <destino>conectar.jsp</destino>
    <usuario>sadsads</usuario>
    <nombreusuario></nombreusuario>
    <perfil></perfil>
    <mensaje>Identificador de usuario o clave erroneos.</mensaje>
    </datos_resultado>

    Thanks again
  • P0UM_Himanshu_Saxena
    1 Post

    Re: Problem sending data from servlet to xfroms

    ‏2012-01-15T11:29:34Z  
    Hi Xabier,
    I am creating a web application and i m using Xform as a presentation layer.
    I am using Xform for the first time , so not much idea about it.
    Please can you help me to find out "how can I invoke the Xforms from my servlet". Please note that there are mutiple xforms in my application and I want to switch xforms as per user interaction
    I am getting data from database(DB2) using webservices and want to forward it to Xforms for display through servlet.

    I am using Xforms and WASCE as the server.
    Thanks in advance....