Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 899
André Avatar asked Nov 16 '11 18:11

André


People also ask

How to set template in NetBeans?

Defined PHP Code Templates To view the code templates that are defined in NetBeans, open Tools > Options (NetBeans > Preferences on Mac), select the Editor features, and select the Code Templates tab. To see the PHP code templates, select PHP in the Languages drop-down list.

How many code templates does NetBeans provide?

You now have two code templates.


1 Answers

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.

like image 116
Jonathan Spooner Avatar answered Nov 15 '22 00:11

Jonathan Spooner