Button click handler and Save form data

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
harris914
Posts: 8

Button click handler and Save form data

Wed Mar 07, 2018 10:45 am

Hello, i'm new to Oxygen XML and starting learning it few days back.

Following the form-controls sample i have created a form in xml file. Some textfields and a button. Now I want to save the form data whatever is entered in the text fields and then button is clicked, just like an HTML form.
How can i achieve it? I have went through the forums and documentation, but somewhat my imagination of its working is a bit blurry.
Please can anybody help me in this regard. Basically there are two things i want to do:
1. Get form data and save it somewhere
2. Button click handler (i associated it with Document Type but it still shows error)

Regards
cristi_talau
Posts: 176

Re: Button click handler and Save form data

Wed Mar 07, 2018 6:06 pm

Hello,

1. Oxygen XML Editor offer you an easy way to edit XML documents in a graphical way. You do not have to submit the form - your changes are saved in the edited XML file when you "save". You mentioned that you wanted to save the data somewhere. Maybe explaining better your use-case will help us provide a better advice.

2. You must bind an Author Action to the button. These actions are defined at a framework level. You can find more about the button form-control here [1]. And about actions here [2].

If you have more questions, please let us know.

Best,
Cristian

[1] https://www.oxygenxml.com/doc/versions/ ... ditor.html
[2] https://www.oxygenxml.com/doc/versions/ ... olbar.html
harris914
Posts: 8

Re: Button click handler and Save form data

Thu Mar 08, 2018 9:10 am

Basically i'm preparing a demo in which i have created a form with three fields using CSS oxy functions.
Now what i want is that when I click the button, I should get the values written in the fields and display them again below the form but not in text fields, rather with just labels.
1. I did bind an action with the button using ActionId, but it showed an error "Document Type not associated." Then I searched for it and by going in Options-> Preferences-> Document Type Association gave reference of my CSS and created an action and gave its id to actionId in the button definition. But no success. Then just to test a thing i did this (save is the tag of button in xml) and it worked but it seemed more of a hack than a proper solution:

Code: Select all

save:before{
    content: oxy_action(
          name, 'Video',
          description, 'Insert an element after the current one',
          operation, 'ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation',
          icon, url('insert.png'),
          arg-fragment, '<video href="https://www.youtube.com/embed/x8r-Pm1-dVc"/>',
          arg-insertLocation, '.',
          arg-insertPosition, 'After'
)
}


2. Also is there a good tutorial or documentation of integrating Oxygen XML SDK in Eclipse. Ifugured from this forum that most of the examples people post here are of Java which means they use Java as a backend of Oxygen. I followed this link:
https://www.oxygenxml.com/oxygen_sdk/download.html
but it does not install SDK and says artifact not found or something when i follow the steps to create a startup project.

Looking forward to a good explanation of it. I'm a bit confused in all it.
Thanks
alex_jitianu
Posts: 652

Re: Button click handler and Save form data

Fri Mar 09, 2018 3:11 pm

Hi,

Now what i want is that when I click the button, I should get the values written in the fields and display them again below the form but not in text fields, rather with just labels.

So these labels are they supposed to be inserted in the document or just rendered, as an overview of what you typed in the form?

I did bind an action with the button using ActionId, but it showed an error "Document Type not associated."

Right, a Document Type must be created an in it you need to specify a set of Association Rules. That's how your XML documents will be matched to this specific Document Type (also referred to as framework). I think you are missing these association rules...

Then just to test a thing i did this (save is the tag of button in xml) and it worked but it seemed more of a hack than a proper solution

I wouldn't call it a hack. If this action is intended to be used just on the button associated with the save element then it makes sense to define it directly in the CSS. So it is also a good approach.

Anyway, if you can send me some sample files (an XML before and after the save button was pressed) as well as the CSS file then I can create the framework for you.

Also is there a good tutorial or documentation of integrating Oxygen XML SDK in Eclipse. Ifugured from this forum that most of the examples people post here are of Java which means they use Java as a backend of Oxygen. I followed this link:
https://www.oxygenxml.com/oxygen_sdk/download.html
but it does not install SDK and says artifact not found or something when i follow the steps to create a startup project.


Have you tried creating the SDK project from Eclipse or from the command line? If you did it from Eclipse, dont forget to specify http://www.oxygenxml.com/maven as the repository URL.

So you intend to use the SDK to customize Oxygen, right? If you can tell me some details abaout what you want to achieve perhaps I can give you more precise details, as what sample project to use as a starting point or what API can help.

Best regards,
Alex Jitianu
harris914
Posts: 8

Re: Button click handler and Save form data

Mon Mar 12, 2018 10:51 am

Hi Alex,

Thank you for your reply. I also tweeted you few days back.

Right, a Document Type must be created an in it you need to specify a set of Association Rules. That's how your XML documents will be matched to this specific Document Type (also referred to as framework). I think you are missing these association rules...

Yes i created an association. in Options -> Preferences -> Document Type Associations i added a framework, referenced CSS. Then Author tab created an action and gave its actionID in the CSS where button was defined. But i got error as described. Then I did this:

Code: Select all

save:before{
    content: oxy_action(
          name, 'Video',
          description, 'Insert an element after the current one',
          operation, 'ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation',
          icon, url('insert.png'),
          arg-fragment, '<video href="https://www.youtube.com/embed/x8r-Pm1-dVc"/>',
          arg-insertLocation, '.',
          arg-insertPosition, 'After'
)
}


Have you tried creating the SDK project from Eclipse or from the command line? If you did it from Eclipse, dont forget to specify http://www.oxygenxml.com/maven as the repository URL.


Yes as mentioned in SDK documentation i created the sample project from command line but it gave me error. Then i searched this forum and following one of the posts i was to create the sample project and upon building that project it showed many errors regarding maven, tomcat unavailability etc.

So you intend to use the SDK to customize Oxygen, right? If you can tell me some details about what you want to achieve perhaps I can give you more precise details, as what sample project to use as a starting point or what API can help.


As we are in the learning phase of Oxygen XML we just want a demo for it in which we can have a form with some text fields, and a save button (which i already have). Now upon button click i want to add some validations on the text fields and if data is in correct form i want to submit form and show those values under form using <p> or any other label tag.
Now there are two things:
1. We can show this XML as html in browser or any other form. I tried to Transform my XML, it shows the process "Applying transformation" in Oxygen XML editor but does nothing. On the other hand when we create a Dita form and apply transformation it shows output in browser as well.

2. How can we use Eclipse ? Or what is the role of eclipse in Oxygen XML?

Please take a look at this scenario and advise me ways to accomplish this. Thank you in advance.
alex_jitianu
Posts: 652

Re: Button click handler and Save form data

Mon Mar 12, 2018 3:32 pm

Hi,

Yes, I remember our conversation on Twitter.

1. We can show this XML as html in browser or any other form. I tried to Transform my XML, it shows the process "Applying transformation" in Oxygen XML editor but does nothing. On the other hand when we create a Dita form and apply transformation it shows output in browser as well.

XML gets published to a specific output, like HTML, by applying XSLT scripts. Oxygen has this concept of a Transformation scenario, which represents a configuration which tells which XSLT get applied and with what options. For Dita Oxygen comes bundled with all the required XSLTs as well as pre-configured transformation scenarios.

You can also create this transformation scenario inside the document type/framework so that all users have access to it after you distribute the framework.

2. How can we use Eclipse ? Or what is the role of eclipse in Oxygen XML?

There are two situation s in which you would use Eclipse:
a. Besides being a Standalone application, Oxygen also has an Eclipse plugin distribution. Why would people use this plugin? Well, Eclipse has a variety of other plugins, each offering different support, so you can create complex environments.
b. Oxygen has a Java based API which can be used for all sorts of customizations. Eclipse, as an Java Integrated development environment, can be used when working with this Java based API (with our SDK).

From what I understand, in your situation, you would need Eclipse to work with our Java based API, perhaps to create a custom author operation.

As we are in the learning phase of Oxygen XML we just want a demo for it in which we can have a form with some text fields, and a save button (which i already have). Now upon button click i want to add some validations on the text fields and if data is in correct form i want to submit form and show those values under form using <p> or any other label tag.


Perhaps an action based on an XSLTOperation can help with this use case. The XSLT script can collect the data from the form, check some requirements and then it can build a new fragment to be inserted after the form. If you go with this operation then you wont need the Oxygen SDK anymore as there is no need to create a custom operation. Do you think you can do everything you need from an XSLT script?

Anyway, it would help if you can send what you have so far (the framework, sample XML, CSS). If I see the framework then I could understand why you aren't able to define the action in it, what's missing.

Yes as mentioned in SDK documentation i created the sample project from command line but it gave me error. Then i searched this forum and following one of the posts i was to create the sample project and upon building that project it showed many errors regarding maven, tomcat unavailability etc.

Chances are that you might not need the SDK, yet. For example is the XSLTOperation is enough. Perhaps if I see the log, the error messages, I might understand what's the problem.

Best regards,
Alex
harris914
Posts: 8

Re: Button click handler and Save form data

Tue Mar 13, 2018 2:27 pm

Hi Alex,

Thanks for your reply.
Can you please give me your email or something where i can send the work i have done till now?
alex_jitianu
Posts: 652

Re: Button click handler and Save form data

Tue Mar 13, 2018 3:12 pm

Hi,

If you send them to support@oxygenxml.com then I will be able to inspect them.

Best regards,
Alex
harris914
Posts: 8

Re: Button click handler and Save form data

Wed Mar 14, 2018 1:30 pm

Hi Alex,

I have sent an email to support@oxygenxml.com .

I was following the following Webinar,
https://www.youtube.com/watch?v=-Ssc4dXRPto

The form that i sent, i applied transformation to it as in this video but when the html got rendered it didn't rendered those text fields and buttons. it just showed the labels.

Any comments on it, please.

Thanks
alex_jitianu
Posts: 652

Re: Button click handler and Save form data

Wed Mar 14, 2018 6:19 pm

Hi Harris,

I've managed to create a framework with some hints about what you can do to achieve your goals and I've just sent it to you.

The form that i sent, i applied transformation to it as in this video but when the html got rendered it didn't rendered those text fields and buttons. it just showed the labels.


You need to work on an XSLT file that matches your own elements and outputs the proper HTML elements. The framework I've sent you contains such a small XSLT but you will have to further develop it according to your requirements.

Best regards,
Alex

Return to “Common Problems”

Who is online

Users browsing this forum: Google [Bot] and 2 guests