I am writing a Java service that will generate a DSP for deleting, updating, and inserting rows into/from a database table. I want to allow the user that generates the DSP to write the file to disk.
Is the UI that handles Code Generation in Developer exposed through an API? Can we create plugins for Developer?
Perhaps I could create a template as the output of my Java service??
A service template will allow you for format service results, but does not help formating the inputs to a service. For this you can use a DSP or JSP (using the WmTomcat package).
But if I understand you correctly, you do not want to create a static DSP. You want to dynamically create an HTML UI. For instance, you want to write pub.db.ui:getUI which has inputs of operationType (insert, update, delete) and tableName.
The user would somehow know to call the service, like clicking on the URL (say in a DSP or JSP): http://host:port/invoke/pub.db.ui:getUI?operationType=insert&tableName=;=hrdb.employee
I would think that there would be at least three services update, insert, delete for each table. Also, you would probably need a query service in order to support update.
You can create a corresponding HTML UI that allows for customized access to each of those three operations:
The output of getUI service would have to be a pipeline that gives you all the data that is needed for a template to create the UI. For instance, you can use %ifval operationType equals(“insert”)% to define the section of the template that should be returned for the insert UI. In that section you would create a FORM that on submit does a POST to the insertHrdbEmployee service and ther rest of the template would create HTML for getting the values appropriate for all the fields of that table.
You can build the HTML string in memory inside getUI and call pub.flow:setResponse to force that as the HTML payload to be returned. You can still use a template for format all or some of the HTML since there are services to run a template you define on the pipeline, so you can view the results as a String.
I’m not aware of any capability for auto-generating DSPs using the Developer’s code-gen features. In fact, in the Developer User Guide for 6.1, it specifically states:
“Note: You cannot use Developer to generate browser-based clients.”
So, if the developer can’t generate DSPs, I’m assuming there is also no API that would support DSP generation.
A DSP is just text, so you can generate it any way you like… There’s no need for an API or anything special:
Hello %value fullName%
is a DSP, so that’s easily produced by just typing the text in, or by concatenating bits of text if something more interesting in terms of generation is required…
Like fred said above: you can call pub.flow:setResponse to set the text that will go back to the user.
If you want to manually run DSPs to use them to generate the text that goes back to the end user, you can do that as well: try pub.report:* services. They let you run DSP syntax on the pipeline or with a given set of inputs… Then just use the output of that when you call setResponse.
PS just to clarify the terms: DSP/Output template syntax is what I’m referring to. In terms of creating a file on disk in the pub directory of a package, that’s technically what makes something a DSP. If you just want to use DSP/Ouput template syntax to produce text, then that’s achievable is what I’m saying…