Jason Johnston wrote:
Kamal Bhatt wrote:
Hi
We have a form that is bound to a java object (so we can copy it to a
db). There is a need for a "preview" button. The idea behind this would
be to take the form as xml data (as opposed to the database), reprocess
it (with an existing XSLT) and open the product of this in another screen..
Currently, we are considering the use of jx templates, but this means
replicating code. I was wondering if there was a way of taking the form,
convert it into XML (perhaps with the XMLAdapter), pass this XML data
back to the sitemap (without destroying the state of the current form)
and eventually pass it to an XSLT to process the form in a separate window.
Trying to understand exactly what you want here... you want the Preview
button to display the preview in a separate window? This can be done
with client-side javascript, but can get tricky.
What do you mean by client side javascript? My problem is that the
website in question has a "general public" view and an input form to
enter the database. The general public will see the page as it appears
in the database, the preview button will simply take the values as they
appear on the input screen and display it as the general public will see
it - if it were in the database. For the sake of maintenance, we
obviously do not want two versions of the same thing hanging about in
two different forms, so we want to use the same XSLT. So at least the
display will be consistent
I was thinking about creating an action in the form definition which
would call a function like this (Note, I have not tested the following
code):
You probably want to make sure that the form is successfully validated
first, which means using fd:submit. This also makes opening the preview
in a new window difficult, since you don't know beforehand if the
validation will be successful (open a new window) or not (redisplay the
form w/errors in the same window).
I implemented a similar Preview function just recently, but it displays
the preview in the same window as the form (actually inline on the same
page as the form).
I did not think of this. I guess the client will have to live with this.
cocoon.sendPage("preview-pipeline", {xml : form.getXML().toString()});
but then what?
If it's just a question of how to get the contents of the "xml" member
streamed into a pipeline's generator, you can do that via the module source:
<map:match pattern="preview-pipeline">
<map:generate src="module:flow-attr:xml" />
<map:transform ... />
<map:serialize />
</map:match>
I am making an assumption here that the toString function actually
returns the XML, I guess I will find out.
I guess another option is to use jx templates to construct the xml and
pass this along to the appropriate xslt. Maybe this isn't such a bad idea.
--
Kamal Bhatt
--
Disclaimer: This email is confidential and may contain privileged information
for the sole use of the person or business to which it is addressed. If you are
not the intended recipient, please notify the sender by return e-mail or phone
as you must not view, disseminate, distribute or copy this email without our
consent. We do not accept any liability in connection with any computer virus,
data corruption, incompleteness, or unauthorised amendment of this email. It is
the sole responsibility of the receiver to scan for viruses before opening.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]