How to add a custom java module into magnolia CMS? - java

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.

Related

Importing template vaadin lose java code reference

I have a JsModule in my vaadin project, so I want to add to my page another, I made this so:
<div><products-search id="products-search"></products-search></div>
It works but there is a problem, the template products-search is related to a java class, if I access directly the page products-search the java binding works, but including the page in another in this way it works partially indeed the layout is visibile but doesn't work the interaction with the java code!
Someone can help me?
If you're importing a custom JS module to your template, the JavaScript code won't know anything about the imported web component's Java companion class. You'll need another approach - you could use #Id binding instead or add a <slot> in your template and append the corresponding Java component on the server.

How to build Angular6 project while having html,css and js files

I am developing a website using angular6 and spring boot with microservice architecture.
I have got the UI from designer team in the form of HTML, CSS, and JS file, whose structure is attached here HTML and CSS files
Also, I had created a angular6 project named DIS, whose structure is attached here Angular6 project
What will be the best way to start with angular 6?
How to include these files in angular6 project considering microservices architecture?
If i understood your question correctly.Yes you can do that.
Step 1: You need to create the Necessary components, Modules needed to build your website.
Step 2: Replace the components with the necessary HTML file and CSS file. As you generate a component with CLI you should have those 2 files just replace them.
When you have global CSS files that can be shared among other files as well. You can configure using Angular CLI.
Regards to microservices architecture, that does not have anything to do with your front end applicaiton, its totally on the server side. But you can consider while creating the components based on the services you have.
ng new ng6-proj --style=scss --routing
Just make changes in the main style.scss that will apply globally.
Images you can keep it anywhere, you just need to use it by providing its path

Spring MVC, how to include another controller/view inside a view (partialview)

I'm just starting out with Spring MVC having been trying to pickup Java(Web) for the few months.
I'm sure what I'm trying to achieve is very simply, but I can't find a solution that really works.
I'd like to include another controller/view inside a view. This could be a menu, or some other dynamically generated content. For example, let's say in a side bar of an application I need to display a list of categories. I don't want to have to retrieve these categories in every controller/view that needs to use them. I'd like to include another controller/view into the main page view so that this content can be placed in multiple views but managed by a single piece of code.
ASP.NET MVC has something called PartialViews, and most PHP frameworks seem to offer this kind of functionality, but I can't find anything like this in spring.
The closest I've come to resolving this issue is to use the jsp:include tag, which does work, infact it's almost the solution, but it generates errors in Eclipse because obviously Eclipse can't locate the path, as it's a spring RequestMapping i.e. /include/categories rather than a direct link to a physical file.
The other solution is to use Javascript to dynamically load content into the sidebar, but I don't want to do that.
Is there a 'correct' way to do this, or is there a way to supress the errors generated by eclipse for the jsp:include tag?
If the content your are including is static and you don't have a lot of different pages, your approach with including jsps is ok. Otherewise, look at the templating frameworks like Tiles or Thymeleaf.

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!
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.

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