why using xml files in form validation in server side? - validation

what is the benefit from using xml files in server side validation, in struts, for example, XML files are used in validation, here's an example http://www.vaannila.com/struts-2/struts-2-example/struts-2-validation-using-xml-example-1.html, and other practise to put all forms specification into XML file and parse it once then cashe the resulted object in order to use it in another time without the need to parse XML file again "the concept of lazy initialization". I want to know why using XML??

1) It's a file that can be configured easily without recompiling the application much the same as an app.config file
2) Advantage over app.config is that this validation file is specific to a single task, reducing the risk that would be incurred if the main app.config was edited and updated.
So basically you can now if you like put a GUI editor in front of the xml file and provide a means for administrators to modify the contents in a live environment.
Storing the data in a database would give you similar benefits, but it's a rather heavy weight solution to the problem.

Related

IBM ODM UI model for json comparision

I have a requirement in which i get two json file in request and I need to copare two json files.
Is there a way within ODM where can show customers the UI for text comparision of json ?
Lets say, json 1 file has a field name which is different from json2 name. I need to show with any report /Ui that this is the difference between two files.
Any help would be appreciated.
Thanks in advance
The ODM user interfaces, either Eclipse-base Rule Designer or web-based Decision Center, allow extensive customization, but these UI's are for authoring the rules, not applying them to input data.
ODM rules are generally run within a server environment, so at execution time there is no user or user interface. It is possible (and feasible and reasonable) to embed ODM execution into any Java program (for example, one with a UI to show or compare differences between JSON document), but ODM does not provide any kind of UI framework for building such a program.
I faced the same problem and used JsonAssert library to compare Jsons in Java.
Best
Emmanuel

Globally rewrite outbound links in a Thymeleaf / Spring MVC / Tomcat stack?

I need to globally rewrite all links to CSS / JS / Images, adding a prefix which will depend on deployment details and is the same across the entire application.
There are hundreds of links on dozen of source HTML templates so modifying at the source (as suggested here for a similar problem) is too error-prone and unsightly.
So I would like to do this programmatically, parsing the outbound HTML, and dynamically replacing each link before the HTML is returned out of the server.
Where to do it?
In Thymeleaf can I intercept the DOM and modify it before it is serialized to HTML?
In Spring MVC can I capture the view output (HTML), parse it, and re-serialize it?
Should I stay "close to the wire" and write a ServletFilter?
Or is it better to write a Tomcat Valve?
How about stepping out of the JVM altogether and have Apache mod_proxy added in front of tomcat just to parse and rewrite?
My initial hunch is that the best place to do it would be Thymeleaf, where there is more context available and it avoids an additional parse/serialize. Why generate wrong data in one layer to have it patched in another, when you could just generate the right data at the outset? Unfortunately the Thymeleaf maintainers don't agree, according to this closed Issue.
I also have this uneasy feeling that I might be reinventing the wheel. Isn't there a generic config option I can set somewhere in one of these layers?
So, to re-state the question objectively, what is the simplest solution - with the fewest lines of code written, and least number of files touched - to globally rewrite all CSS/JS/IMG links in a web application at run-time based on an application-specific algorithm?

Include source code from different directory

I have three different domains all on the same server and I want to run the code on all three domains from one source on the same server, but not sure the best way.
Here's what I have:
domain01.com
domain02.com
domain03.com
domain04.com/sourcecode
I want domain01-03 to run the code inside domain04.com/sourcecode so the user can go to their domain and not have to go to domain04.com to see their site. I want to keep all the code inside domain04.com because I don't want to have to put the code inside each domain every time I make a code change.
For whatever reason I can't get my head around the best way to do this -- and want to do it right.
Any advice?
Thanks!
All you need to do is create a mapping on the first three sites to the appropriate directory in the fourth site, eg map /domain04 to /full/path/to/domain04/sourcecode, then refererence its CFML resources via /domain04 in CFC and include paths. The inference here is the code does need to be accessible via the file system for all sites concerned.
Note that if you also want to server non-CFML files via HTTP (eg: images, css, js), then you will also need a web server virtual directory along the same lines.
None of this requires a framework, it's standard CF / web server functionality.
Are you using a framework? One like ColdBox could make this trivial if your code is written modularly. (Disclaimer, I am affiliated with ColdBox)
If not, it really depends on what the code is. CFCs can be mapped anywhere via ColdFusion mappings. Even .cfm files can be included as long as the file systems are visible. If you're wanting to basically have complete copy of a site in another web root without duplication, I would first consider using a shared source control repo and a build process that checks it out in the appropriate places, and secondly a good old, symlink will also work .

Populate file list with previously uploaded files

Using the jQuery wrapped version of Fineuploader v3.3.
Is it possible to populate the file list with files already in the upload folder?
I think "_addToList(id, name)" should do the trick, but I can't get it to work. Any ideas?
Seems that they are currently working on this feature:
https://github.com/Widen/fine-uploader/issues/784
So, this will be available soon.
This is not a behavior that Fine Uploader currently supports. Fine Uploader only displays files that users have submitted to the uploader since the current uploader instance was created. It doesn't try to be an all-in-one web application. You could probably add your own item to the list/UI via javascript. That probably wouldn't be terribly difficult, but seems like an odd thing to do.
If you'd like to discuss your specific use case more, please open up a feature request in the Github issue tracker.
Generally, client side code cannot add stored or hard-coded path based file names for use in any type of POST or upload operation. Obviously this is a security measure, you can imagine if a malicious web page could add to a generic POST operation some type of baked in file name. So from what I understand, only the user can specify path based file names, via a file browser for the session that it is included in. This applies to HTML/JavaScript/jQuery but am unsure if Flash/Silverlight based solutions would also be limited. I think a Java based uploader would be free of this. But you are just moving closer and closer to installed software.

How can I copy an event into Plone with WebDAV?

Is there way to copy a file into Plone with WebDAV and have Plone register it as an Event file (rather than a simple page)?
I would very much like to use Plone for it's standard CMS properties (which are brilliant) but I can't spend time programming up an application in Plone - it's way too complicated. The "Plan" is to generate information in another system and use scripts to export it into Plone - hence copying via WebDAV would be a perfect solution if these generated files could be recognized as Events.
If not an alternative, still using WebDAV, would be to generate and copy a python script, that uses API calls to create the events. Though I'm not sure where to copy and what API calls to make.
Or is there a way of importing iCal files?
Thanks
You can customize the code to accomplish any end -- but by default, out-of-the-box, you need to:
Upload text files with the file name extension .event -- you can edit this in the content type registry tool in the root of your Plone site. This tells the folder what type of item to create (an event).
Format you text file using RFC822-style key-value formatting (like mail headers or HTTP headers are formatted) in a text file you upload via WebDAV. You must use IS0 8601 formatted (YYYY-MM-DDThh:ss:mmTZD) timestamps for all date/time field values.
If in doubt on the specifics of the last point, refer to the source code in Products.Archetypes.Marshall.RFC822Marshaller and DateTime.DateTime (zope2).
If you wish to customize the marshaller in use, you could write your own marshaller, and monkey-patch ATEvent to use it. This would allow you to support upload/download of vcs/ics if you wrote the code to do so. This is NOT the path of least resistance. YMMV, this is under-documented, and requires some serious Plone development experience.

Resources