Send Button sample

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Send Button sample

javaudvikling
Hi,

Can anyone give me a code sample of implementing a webservice Call in orbeon with the pdf and data XML when pressing the Send Button on a published form.
I have tried some of the samples on the net but it seems that they are out of date...

Thanks for your help..
Reply | Threaded
Open this post in threaded view
|

Re: Send Button sample

mpasko78
Here is an example, of at least getting the primary template to edit a form:

@Path("/api/orbeon/crud")
@Service
public class OrbeonBuilderPersistenceWebService {

/**
         * Gets the published template
         * @param appName
         * @param formName
         * @param request - HttpServletRequest used to get Session
         * @return -Status HTTP OK, or BAD_REQUEST
         * @throws RestApplicationException
         */
        @Path("/{AppName}/{FormName}/form/form.xhtml")
        @GET
        @Produces(MediaType.APPLICATION_XML)
        @RestAuthentication
        public String getOrbeonBuilderPublished(@PathParam("AppName") String appName, @PathParam("FormName") String formName, @Context HttpServletRequest request) throws RestApplicationException {

       
                // For orbeon/library, always use the generic template on Orbeon (this is for the toolbox to show up when editing a template)
                if (formName.equals("library")) {
                        log.debug("***** Orbeon/Library is app specific template, generic and on Orbeon.");
                        throw new RestApplicationException(Response.Status.OK,"");
                }
               
                try{
                        TemplateData data=orbeonService.getTemplateData(formName, null);
                        String dataXml=data.getTemplateData();
                        return dataXml;
                       
                } catch (Exception e) {
                        log.error(e.getMessage(),e);
                        throw new RestApplicationException(Response.Status.BAD_REQUEST,e.getMessage());
                }
               
        }
}

Here are the integration points:
Integration points:
-- Save the form template (HTTP Methods GET, PUT)
/api/orbeon/crud/orbeon/builder/data/{formId}/data.xml
-- Save the form template attachment (HTTP Methods GET, PUT)
/api/orbeon/orbeon/builder/data/{formId}/{attachmentId}.bin

-- Save/Get the PUBLISHED template (HTTP Methods GET, PUT)
/api/orbeon/{AppName}/{FormName}/form/form.xhtml
-- Save/Get the PUBLISHED template DATA (HTTP Methods GET, PUT)
/api/orbeon/{AppName}/{FormName}/data/{FormDataId}/data.xml
-- Save/Get the PUBLISHED template attachment (HTTP Methods GET, PUT)
/api/orbeon/{AppName}/{FormName}/form/{attachmentId}.bin

And be sure to modify WEB-INF/resources/config/properties-local.xml, and adding your base REST URL:
         <property as="xs:string" name="oxf.fr.persistence.provider.*.*.*" value="test"/>
         <property as="xs:anyURI" name="oxf.fr.persistence.test.uri" value="http://localhost:8080/test/api/orbeon/"/>

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Send Button sample

Erik Bruchez
Administrator
In reply to this post by javaudvikling
With 4.3 and newer, you can configure a button which sends both, in sequence:

- the XML data
- a link to the PDF

https://github.com/orbeon/orbeon-forms/wiki/Form-Runner:-Buttons-and-Processes

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Send Button sample

javaudvikling
Hi,

Thanks for your answers.. but I don't think that i have stated my question correctly.

First I'm new to Orbeon and xpath and understand how it works after discussion in this forum..

What I want to see is a code sample that illustrate how to implement a service call when pressing the Send button and how to define that it should incl. the pdf, xml and e.g. uploaded attachments.
This mean, where do I implement that e.g. in which file/files and the syntax.  

I studied the link and sample code, but have some difficulties...

Thanks in advance..
 
Reply | Threaded
Open this post in threaded view
|

Re: Send Button sample

Erik Bruchez
Administrator
The "Send" button and action currently (with 4.3) can only send the XML data or a URL to the local PDF file. You configure this with properties, as documented here:

https://github.com/orbeon/orbeon-forms/wiki/Form-Runner:-Buttons-and-Processes

We do hope to allow for sending attachments as well at some point, using maybe a multipart POST.

However, if you use the "Save" button, then all attachments are stored into the database. Some users implement their own persistence layer using our API:

http://wiki.orbeon.com/forms/doc/developer-guide/form-runner/persistence-api

I have replied separately to your other question about sample code to implement a service.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Send Button sample

javaudvikling
Hi Erik,

Thanks for your answer.

Does this mean that from 4.4 when i press send, the attachments will also not be not saved in DB and only be saved when i press the save button?

Mvh
Balatharan
Reply | Threaded
Open this post in threaded view
|

Re: Send Button sample

Alessandro  Vernet
Administrator
Hi Balatharan,

javaudvikling wrote
Does this mean that from 4.4 when i press send, the attachments will also not be not saved in DB and only be saved when i press the save button?
Right, but I don't think this is new. In 4.3, send is defined as: require-uploads then validate-all then send("oxf.fr.detail.send.success"). And this hasn't changed in 4.4. Or were you referring to something else?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet