Generating views dynamically

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

Generating views dynamically

chary-2

I would like to generate a view dynamically based on the model at hand.
In order to do this, a view="foo.xpl" needs to be defined in the
page-flow.xml. I would like to write a Java processor that can be
invoked in this (foo.xpl) pipeline. This Java processor will generate
XFORMS code including the Model and View which will be sent to the
epilogue.xpl for rendering in HTML. I would like to see an example of
such a Java code if anyone out there has it.

Thanks,
Chary

 




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Generating views dynamically

damonrand
Hi Chary,

    I presume you mean you want to see an example of the oxf-java code
rather than something to do the model-view processing.. Here is the basic
skeleton I am using.. Hope it gives you the a starting point.

Regards,
Damon.



public class AdamSessionProcessor extends SimpleProcessor {

   public AdamSessionProcessor() {
        super();

        addInputInfo(new ProcessorInputOutputInfo("config"));
        addOutputInfo(new ProcessorInputOutputInfo("data"));

    }

    public void generateData(
            org.orbeon.oxf.pipeline.api.PipelineContext context,
            ContentHandler contentHandler) {

        try {

            // Get HTTP request info from config
            Document config = readInputAsDOM4J(context, "config");
            Element root = config.getRootElement();
            if (!root.getName().equals("config"))
                throw new IllegalArgumentException("<config/> input is
invalid");
            String methodName = root.getText();

            Map inputs = this.getConnectedInputs();

            // Dynamically add each input (apart from config) to a
parameterList
            List messages = new ArrayList();
            Iterator it = inputs.keySet().iterator();
            while (it.hasNext()) {

                String entry = (String) it.next();

                if (!entry.equalsIgnoreCase("config")) {
                    org.dom4j.Document message =
this.readInputAsDOM4J(context,
                            entry);
                    messages.add(message.asXML());
                }

            }

            // Do some stuff.................
            // String result = "<xmlhere/>"

            // Generate output from string
            // TODO Find a cleaner way to serialize?
            LocationSAXWriter writer = new LocationSAXWriter();
            writer.setContentHandler(contentHandler);
            Document resultDoc = DocumentHelper.parseText(result);
            writer.write(resultDoc);

        } catch (Exception e) {
            throw new OXFException(e);
        }
    }

}


----- Original Message -----
From: "chary" <[hidden email]>
To: <[hidden email]>
Sent: Monday, September 05, 2005 3:28 PM
Subject: [ops-users] Generating views dynamically


>
> I would like to generate a view dynamically based on the model at hand.
> In order to do this, a view="foo.xpl" needs to be defined in the
> page-flow.xml. I would like to write a Java processor that can be
> invoked in this (foo.xpl) pipeline. This Java processor will generate
> XFORMS code including the Model and View which will be sent to the
> epilogue.xpl for rendering in HTML. I would like to see an example of
> such a Java code if anyone out there has it.
>
> Thanks,
> Chary
>
>
>
>
>

--------------------------------------------------------------------------------


>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws