-
New open source library: VMC Injection (13 messages)
- Posted by: Mark S
- Posted on: August 05 2009 09:38 EDT
At our company (vmcreative.com.au) we have started up an open source section (oss.vmcreative.com.au) and we have released our first open source library. The library, called VMC Injection, allows any Java data structure: (JDBC, POJOs, HashMaps etc) to be inserted/injected very easily into a text (HTML/XML etc) template. We use this library in our commercial offerings (web applications) to generate dynamic web pages with servlets, xml generation and latex template generation. This is our first attempt at releasing and managing an open source project and we are looking for feedback. Our open source projects are completely free and are released under the Apache 2 license. A quick example of what you can do with our library: to embed a JDBC ResultSet into a HTML file and return it via a servlet: ShowCustomer.html: Id: #id Name: #name Address: #address Phone: #phone Email: #email ---------------------------------------------------- ShowCustomer.java: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Target InjectionTarget htmlTarget = new HTMLInjectionTarget("ShowCustomer.html"); // Data ResultSet rs = getCustomers(); HashMap injections = new HashMap(); injections.put("Customers", new SQLInjection(rs)); // Stream response.setContentType(CONTENT_TYPE); OutputStream out = response.getOutputStream(); InjectionStreamer injectionStreamer; injectionStreamer = new injectionStreamer(htmlTarget); injectionStreamer.streamTo(out, injections); } -------------------------------------------------- A couple of the aims of the project are: 1) Completely separate the text/template files (HTML/XML etc) from the program code so they can be worked on ndependently. 2) Allow any Java structure to be inserted without the need to use specific access methods of that structure and avoid having to write loops for structures that have multiple entries (ResultSets, Lists and Arrays etc). 3) Formatting of fields using Java's standard formatting classes (not shown in example above, see the website) More information and download of the library is available at the projects home page: http://oss.vmcreative.com.au/VMCInjection.html We are really interested to find out if people like our idea and any other general opinions they may have of what we are doing. Regards, Mark oss.vmcreative.com.auThreaded Messages (13)
- SQLInjection? by Matthew Passell on August 05 2009 10:49 EDT
- Re: SQLInjection? by Steven Goldsmith on August 05 2009 11:12 EDT
-
Re: SQLInjection? by Nicolas Bousquet on August 05 2009 11:31 EDT
- Re: SQLInjection? by Mark S on October 17 2009 10:19 EDT
- Re: SQLInjection? by Mark S on October 17 2009 10:16 EDT
-
Re: SQLInjection? by Nicolas Bousquet on August 05 2009 11:31 EDT
- How is the spam getting through recaptcha by Mncedisi Kasper on August 07 2009 00:34 EDT
- Suggestion by James Tan on August 09 2009 10:55 EDT
- Does not work with JSP by James Tan on August 10 2009 05:34 EDT
- Re: Suggestion by Mark S on October 17 2009 10:38 EDT
- Re: SQLInjection? by Steven Goldsmith on August 05 2009 11:12 EDT
- Hummm just another velocity with extra feature by Sergio Amim on August 05 2009 14:56 EDT
- Re: Hummm just another velocity with extra feature by Mark S on October 17 2009 22:53 EDT
- Re: New open source library: VMC Injection by Mark S on October 17 2009 22:45 EDT
- Re: New open source library: VMC Injection by Mark S on October 17 2009 22:55 EDT
-
SQLInjection?[ Go to top ]
- Posted by: Matthew Passell
- Posted on: August 05 2009 10:49 EDT
- in response to Mark S
I'm not sure that you want to associate the term SQL injection with your project. ;) --Matt -
Re: SQLInjection?[ Go to top ]
- Posted by: Steven Goldsmith
- Posted on: August 05 2009 11:12 EDT
- in response to Matthew Passell
How is this different from Velocity or any other general purpose template framework? -
Re: SQLInjection?[ Go to top ]
- Posted by: Nicolas Bousquet
- Posted on: August 05 2009 11:31 EDT
- in response to Steven Goldsmith
Same question as Steven Goldsmith : Why don't just use existing templating engine or jsp/tagfiles ? -
Re: SQLInjection?[ Go to top ]
- Posted by: Mark S
- Posted on: October 17 2009 22:19 EDT
- in response to Nicolas Bousquet
Same question as Steven Goldsmith :
It was a chance to try something new and attempt to improve the way things are done. Also this eliminates the need to learn jsp.
Why don't just use existing templating engine or jsp/tagfiles ? -
Re: SQLInjection?[ Go to top ]
- Posted by: Mark S
- Posted on: October 17 2009 22:16 EDT
- in response to Steven Goldsmith
One of the main differences is the simplicity of the template, no logic or functions are allowed in the template. The design also allows different template styles to be created. There is also direct support for the standard Java formatting classes. -
How is the spam getting through recaptcha[ Go to top ]
- Posted by: Mncedisi Kasper
- Posted on: August 07 2009 00:34 EDT
- in response to Matthew Passell
Can someone from serverside please tell me how this spam is getting through recaptcha. We're building a site and using recaptcha to limit the spam, so it would be really interesting to find out if we're not just wasting our time -
Suggestion[ Go to top ]
- Posted by: James Tan
- Posted on: August 09 2009 10:55 EDT
- in response to Matthew Passell
I just like to comment about why I like VMC. It seems like a lot of framework like Struts, Spring MVC, Webwork etc are heavyweight, trying to do a lot of wiring and infrastructure plumbing to serve the needs for all types of web apps. I think that makes things unnecessarily complex, especially for simple web apps. The good point about VMC is simplicity, much simpler than template framework like Velocity for instance, if that can be a good comparison. One do not need to have too much knowledge about VMC, like providing all sorts of framework dependant import statements in the HTML/JSP. And this is a good thing as there is no "knowledge" of HTML coupled directly to VMC, except the facts that it contains VMC specific tag and # prefixed fields. It will be good if VMC could inject HTML based on CSS class or id, then that will make the HTML truely loosely coupled from even VMC! :) For instance, instead of using irow, igroup or iwindow, maybe VM could use ..., ... or ...? In this case, the browser still can choose to the display the text within span tag instead of ignoring them? Just a thought. I also have a question, does VMC support any POSTing back and saving the values of the fields, injected previously by VMC POJO for instance? In Spring MVC for instance, that will be known as Spring binding. If VMC support automatic binding to the model or the POJO or whatever you call it in VMC's programming model, that would be awesome! -
Does not work with JSP[ Go to top ]
- Posted by: James Tan
- Posted on: August 10 2009 17:34 EDT
- in response to James Tan
The sample given by this project was written in servlet, it will not work in JSP out of the box. One will receive the error - java.lang.IllegalStateException or getWriter() has already been called for this response This is due to OutputStream out = response.getOutputStream(); I think the method that need to be changed is injectionStreamer.streamTo which should not take Outputstream but rather JSPWriter or JSP's out. -
Re: Suggestion[ Go to top ]
- Posted by: Mark S
- Posted on: October 17 2009 22:38 EDT
- in response to James Tan
I just like to comment about why I like VMC. It seems like a lot of framework like Struts, Spring MVC, Webwork etc are heavyweight, trying to do a lot of wiring and infrastructure plumbing to serve the needs for all types of web apps. I think that makes things unnecessarily complex, especially for simple web apps.
Simplicity is definitely what we're aiming for and I'm always looking to simplify what we have even more. The span idea is a great one and as I mentioned above the design allows for different template styles and it definitely an idea I'm going to take on board.
The good point about VMC is simplicity, much simpler than template framework like Velocity for instance, if that can be a good comparison. One do not need to have too much knowledge about VMC, like providing all sorts of framework dependant import statements in the HTML/JSP. And this is a good thing as there is no "knowledge" of HTML coupled directly to VMC, except the facts that it contains VMC specific tag and # prefixed fields.
It will be good if VMC could inject HTML based on CSS class or id, then that will make the HTML truely loosely coupled from even VMC! :) For instance, instead of using irow, igroup or iwindow, maybe VM could use ..., ... or ...? In this case, the browser still can choose to the display the text within span tag instead of ignoring them?Just a thought.
As mentioned above we have some support classes that we use that we haven't had a chance to open sourced yet, which I think after reading this maybe the next step.
I also have a question, does VMC support any POSTing back and saving the values of the fields, injected previously by VMC POJO for instance? In Spring MVC for instance, that will be known as Spring binding. If VMC support automatic binding to the model or the POJO or whatever you call it in VMC's programming model, that would be awesome! -
Hummm just another velocity with extra feature[ Go to top ]
- Posted by: Sergio Amim
- Posted on: August 05 2009 14:56 EDT
- in response to Mark S
Your view need to know name that was used on data base, it is bad, not!? Maybe .Net guys whant use it :P -
Re: Hummm just another velocity with extra feature[ Go to top ]
- Posted by: Mark S
- Posted on: October 17 2009 22:53 EDT
- in response to Sergio Amim
Your view need to know name that was used on data base, it is bad, not!?
Can you explain what you mean?
Maybe .Net guys whant use it :P -
Re: New open source library: VMC Injection[ Go to top ]
- Posted by: Mark S
- Posted on: October 17 2009 22:45 EDT
- in response to Mark S
A quick apology for the late replies as I didn't realise the server side had accepted this post. We are always looking to evolve the design and functionality of our projects so thanks for the input and let me know if you have any more ideas. Thanks, Mark :) -
Re: New open source library: VMC Injection[ Go to top ]
- Posted by: Mark S
- Posted on: October 17 2009 22:55 EDT
- in response to Mark S
Also not mentioned is that we have support for "paging" for long list of records/objects and automatically generating page numbers