How to create Netbeans templates that create more than 1 file?

One of the most amazing features of Netbeans is code generation using some FreeMarker templates. I have some questions about this, I hope someone here can help me.

How can I create a template on Netbeans that generates more than just one file?

For example, I use the "JSF Pages From Entity Beans" wizard to create CRUD files . Therefore, it automatically creates 4 files for every object that I have:

- Create.xhtml - Edit.xhtml - List.xhtml - View.xhtml 

This is very useful because you often need to create, edit, view or view some records from your database. Therefore, I know that I can edit each template separately by clicking Tools β†’ Templates β†’ JavaServer Faces β†’ JSF Entity β†’ View.xhtml . And then I can change the way of creating View.xhtml . Then the FTL file is created in "C: \ Users \ yourname \ .netbeans \ 6.9 \ config \ Templates \ JSF \ JSF_From_Entity_Wizard \ view.ftl" .

But I need more, I need a search page. My question is how can I create or modify a template, for example "JSF Pages From Entity Beans", which generates not only 1 file, but also 4 for each object. Therefore, I can modify this template to generate 5 files:

 - Create.xhtml - Edit.xhtml - List.xhtml - View.xhtml - Search.xhtml (for example) 

Thanks in advance!

+6
source share
1 answer

You can create your own project template. Here are some instructions for this:

http://netbeans.dzone.com/tips/hack-your-own-custom-project-t

So, you can create a new project and use the "JSF Pages From Entity Beans" wizard, and then add your own files. Then you should go from step 2 to the specified link and create a template.

Change After I thought about this, I think that what you are really looking for is to create a file template module:

http://platform.netbeans.org/tutorials/60/nbm-filetemplates.html

Edit 2: Based on your comment, I submit a URL to Geertjan's blog for a brief description of how to create multiple files from one wizard *. However, after more thought, I understand that this is also not what you want. What you really need is the ability to add another file to an existing wizard (Entity JSF). This, of course, is possible, but not as simple as creating your own wizard, since the only way to do this is to change the source code for this particular module (JSF support).

* Understand that the above guide only shows a fragment of how to create your own wizard for creating new files. There are several aspects that are supposed to be understood and not discussed.

+3
source

Source: https://habr.com/ru/post/901648/


All Articles