-
-
Notifications
You must be signed in to change notification settings - Fork 1
My First Website
Marc Magon edited this page Feb 17, 2017
·
3 revisions
This page will detail how to create your first website from scratch, using the core framework.
- Step 1 – Create new Java Class extending JWebSwingServlet
- Step 2 – Annotate with @Singleton
- Step 3 – Override the two required methods, getUrl, and getPage
The code should look something like the below
@Singleton
public class BasicAppTemplate extends JWebSwingServlet
{
@Override
public Page getPage()
{
return new Page();
}
@Override
public String getUrl()
{
return "/";
}
}
At this point you are ready to run your application and produce a blank page.
You do not need any configuration files for any web server, or EE server in any regard, the application will run.
The framework is intended as a code only implementation (although not restricted at all).
You can generate everything from any component (including the page) and output to a console if need be.
- You need to explicitly set the singleton annotation
a. By default, all servlets are singletons and highly threaded.
b. When managed with an external injector (such as WELD or CDI) these apply singletons for you, when using an internal dependency injector, the annotation is needed to be applied directly to the class.
c. Don’t worry, you’ll get a nice error message if you forget to do this - The URL provided is in relation to the context of the war file
a. If your context is specified as abc, and the url is cba the visiting address is
i. http://<server>/abc/cba
b. To map to the same address as your context use “/”
i. http://<server>/abc/
c. All URL’s can be appended with query parameters
d. If you’re specifying custom servlets, remember to append the query regular expression
i. A protected variable “QueryParametersRegex” is available from any GuiceSiteBinder - It’s usually best for largish applications to have the Page in a separate class.
- The page is tightly bound to the body, using getBody() is usually enough.
- You can of course use setBody() to have them loosely coupled.
- Netbeans
- Eclipse
- IntelliJ
- Basic Structure
- Code Explanation
- Run Everywhere
- The Default Binder
- The Site Binder
- Quick User Authentication Filter
- Serialize to JSON
- Deserialize from JSON
- The Page Configurator
- HTML Only
- HTML with JS
- HTML with JS and CSS
- HTML with Angular, JS, and CSS
- HTML with All, and a custom servlet
- A Complete Plugin