How to make Netbeans' templates that creates more than 1 file? - java

One of the most awesome features of Netbeans is to generate code using some FreeMarker templates. I have some questions about it, I hope someone here can help me.
How can I make a template on Netbeans that generates more than just 1 file?
For example, I use the "JSF Pages From Entity Beans" wizard to generate CRUD files. So it creates automatically 4 files for each entity I have:
- Create.xhtml
- Edit.xhtml
- List.xhtml
- View.xhtml
This is very useful, because you often needs to create, edit, list or view some records from your database. So I know I can edit each template individually by clicking on Tools -> Templates -> JavaServer Faces -> JSF entity -> View.xhtml. And then I can change the way View.xhtml is generated. Then a FTL file is created on "C:\Users\yourname\.netbeans\6.9\config\Templates\JSF\JSF_From_Entity_Wizard\view.ftl".
But I want more, I need also a Search page. My question is how can I make or change a template like "JSF Pages From Entity Beans" that generates not only 1 file, but 4 for each entity. So I can change this template to generate 5 files:
- Create.xhtml
- Edit.xhtml
- List.xhtml
- View.xhtml
- Search.xhtml (for example)
Thanks in advance!

You could create your own project template. Here's some instructions for doing that:
http://netbeans.dzone.com/tips/hack-your-own-custom-project-t
So, you could create a new project and use the "JSF Pages From Entity Beans" wizard and then add your own files. Then you would follow from step 2 of the above link and create the template.
Edit After giving this some more thought I think that what you're really looking for is creating a File Template Module:
http://platform.netbeans.org/tutorials/60/nbm-filetemplates.html
Edit 2: Based on your comment I'm posting a url to Geertjan's blog for a short description on how to create multiple files from a single wizard*. However, after more reflection I understand that this is also not what you want. What you really want is the ability to add another file to an existing wizard (JSF from Entity). This is of course possible but not as simple as creating your own wizard as the only way to do such a thing is to modify the source code for that particular module (JSF Support).
*Understand that the above tutorial is showing only a snippet of how to create your own New File wizard. There are a few aspects that are assumed to be understood already and not discussed.

Related

How to add a custom java module into magnolia CMS?

I have created a minimal web app with maven following the tutorial
I want to add my own Java components into the webapp. I found these guides: guide1 and guide2
But I still cannot make a page in Pages App using templates from links above (just do not have that templates)
What am I doing wrong? Should I try smth else? Thanks.
There are 2 types of templates that Magnolia supports if you want to use it to render content as well as supply it. There is a page template that is associated with over page and then there is a component template that is used to render components within the page. Each page can have only one page template associated with them while it can contain multiple components of different type and multiple instances of those components as well.
From what I can see, your first guide will only create structure for templates in the generated module, but not actual templates. And your second guide will only create templating function and component template to demonstrate that function, but not a page template.
So first, you should check that in your module structure, somewhere under /src/main/resources/<your module name>/templates you have subfolder called pages and in that folder you have defined page template. And second, you might want to follow this guide for creating and registering page template.
Or if you want to skip java module altogether and do it just as a light module you can follow the guide here.

How to Add a Javadoc Directory to a Wordpress Site

I am hosting a Wordpress site and would like to use it to publish an open source project. I'd like one of the main menu items to link to the javadoc for the project. For those, unfamiliar with Java, javadoc is a programmatically generated directory hierarchy with many (too many to convert manually) HTML files. The root level contains the index.html file that you start with and all the references are relative to that directory. How can I hook in this structure to the WP site? Converting each page by hand to a WP page is not an acceptable solution because there are too many of them and they change regularly.
The following worked for me:
Within my WordPress folder I created a folder javadoc - right next to wp-admin and the like - and dumped all the created JavaDoc-html in there. Going to http://my-blog/javadoc nicely displays the docs.
I'm a novice in this area, so this might be inadvisable from a best practice or security point of view. I'm actually very interested in an opinion on that!

How to render plain html in Play 2.0

I'm working on learning JSP and the Play framework, and I understand that it runs on Scala and renders views based on templates, but what if I just want to use plain HTML rather than scala templates?
The situation I'm in is that I'm designing the site to match a visual template, so I'm using Dreamweaver to build the html files. I really like Play framework though, so I'd like to continue using it. So, what are my options here?
I don't get. Play's views are not just nice html files, of course you can (or even should) use your favorite tools for design part, anyway you have to also learn how to include a dynamic parts in it.
Of course you can use DreamWeaver for that task as it has feature for editing source code. But I can ensure you from my own experience, that there are better tools for every-day work with Play's views than DW.
You can also use plain HTML in your /public folder however in this scenario you won't be able to make it dynamic, so it has no sense, as you can create the pages without any framework - just using static files created with DW.
In general words: you need to verify your needs, cause from your question I read: "I like Play framework, anyway I don't want to use it for its job..."
After-comments edit:
You don't have to make views dynamic. If you won't pass any arguments into the view and will put there pure HTML it will be 'relatively cheap' way for displaying static pages as well. Just you need to remeber to leave first line of the file empty. So you don't need to use File index = new File... instead just put your bare HTML code into ie: app/views/staticContact.scala.html and then use an action:
public static Result staticContact(){
return ok(views.html.staticContact.render());
}
On the quite other hand, last time I was wondering if it wasn't better to put HTML code of the static pages into the DB, in such case you could create an editing page, where you could change HTML without redeploying the application. All what you will need it was just fetching HTML from DB and displaying it in one generic view. For better performance you can use included Cache implementation.
GET / controllers.Assets.at(path="/public/html", file="index.html")
This is working for play 2.0.1 for /public/html/index.html file

Converting a UML class diagram created using Papyrus into an .ecore file

Here is what I do using eclipse :
Create a new Papyrus project
Create a class diagram in Papyrus
Create a new EMF empty project
Use the EMF Generator Model to convert my .uml file (created with Papyrus) into an .ecore file
Now i would like to do that in Java. I found a post here where someone is doing it from XSD. I would like to do the same thing but from UML. User565300 is using something called Xsd2Ecore but I couldn't find a Uml2Ecore. Do you guys know what eclipse is using to convert UML file ?
I happened to bump into this problem very recently and found an easy solution so thought I would share.
In addition to Papyrus, I have the Obeo UML Designer 6.1 plugin installed.
1) UML Designer adds a concept of a "Modeling Project". Create one from the File->New submenu.
2) Find the Papyrus model you want to convert to ECore. Under its root node you will generally see two children labeled "notation" and "uml". The node labeled "uml" corresponds to a file called "model.uml". Click it and copy the file path to the clipboard.
3) Return to your Modeling Project. Paste your clipboard into it, and you should see "model .uml" appear. Open it.
4) Open the "root resource node" and select its single child, which will be referred to below as the "root model node".
-- This should be a UML model object representing the root of the model you are porting.
-- If you see something else, check whether you failed to overwrite a pre-existing file or copied the wrong model source .
5) Make sure you are on the Modeling perspective and see the "UML Editor" menu. With the root model node still highlighted, navigate to "Convert To" -> "Ecore Model..."
6) Complete the wizard. Correct any errors and reepat if necessary.
The Obeo Designer is an open source project available on GitHub, so I imagine its possible to pick apart the Manifest file to identify the menu contribution for "To Ecore..." and then locate the actual source code through GitHub.
Papyrus is an UML Editor which requires other plugins. You need to use another plugin such as accelero in order to generate code but to be honest it seems that since Eclipse 3.5 this plugin is not really working with the latest releases.
The best would be to swap to Topcased which is modeling development environment including code generation. The only problem is that Topcased has been abandoned in order to be merged inside Papurus MDT so it is better not to invest in this tool today and stick to Papyrus MDT.
Creating ecore model from papyrus is impossible because it works with a GMF model and not directly from an Ecore model. GMF being also abandoned since Eclipse 3.5 I don't know what to say ...
Good luck,

Newbie Question about Web Content Display and Templates

Im using Liferay Portal v5.2.3 Community Edition. I have the following two questions which i hope someone would be kind enough to answer.
1.) I want to add some content to the About Us Page of my intranet portal. I added Web Content Display portlet, and maximized the screen after adding content. But accessing the portal, it always appears minimized.
Any way to solve this issue ?
2.) When i try to add a template after creating a structure, i have to select the script file to be used. I found some vm files for 7Cogs portal,but couldnt find any for the organization i created . Where are these vm or css files located and which one to use ?
Please Help.
Thank You.
For 1) There's no need to "maximize" anything if that's the only thing you have on a page. Just choose the single-column layout and place your Web Content in this single column that covers the whole screen.
For 2) you'll have to add the templates yourself. Every template belongs to a structure, so if you create your own structure, you also need to create templates that can display this structure.
You create templates in the same place you create structures: Go to the Control Panel. In the "Web Content" section you find tabs for structures and templates. When you create a template you need to specify a matching structure there. Once you've done that you can choose that template in your web content

Categories

Resources