Loop list data in Java Spring Boot with Primefaces - java

Hello so i wanted to make a little projects, but i'm currently don't know the "keyword" to search for it. I wanted to make a job applying site, and how do i list all the job from job table in the so like "bootstrap card" but in Primefaces?
Fyi: The region is from Region table.
I don't know what to search the keyword for it...

PrimeFaces is an open-source user interface (UI) component library, the following components may help you to achieve your goal :
NAVBAR: https://www.primefaces.org/showcase/ui/menu/menubar.xhtml
SIDE MENU: https://www.primefaces.org/showcase/ui/menu/slideMenu.xhtml
CARD: https://www.primefaces.org/showcase/ui/data/datagrid/basic.xhtml
How to use Primefaces
You just need to download PrimeFaces, add the primefaces-{version}.jar to your classpath and import the namespace to get started.
PrimeFaces namespace is necessary to add PrimeFaces components to your pages.
xmlns:p="http://primefaces.org/ui"
For PrimeFaces Mobile, the namespace would be;
xmlns:p="http://primefaces.org/mobile"
That’s it 🙂
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:spinner />
</h:body>
</html>

Related

Java Applet works in Firefox only

I have implemented a Java Applet.
I have exported the jar.
I signed the jar.
And it works if I put it on my server and use it with HTML.
But only in Firefox.
Here is the HTML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Upload Test</title>
</head>
<body>
<object archive="applet.jar" classid="java:uploader/FileUpload.class"
codetype="application/java-vm" width="800" height="600"> </object>
</body>
</html>
I also tried it with this:
<SCRIPT type="text/javascript">
if(browser.value.getIndex("chrome") {
chrome.browser.enableFeature(JApplet)
});
</SCRIPT>
But still Firefox only.
I would really like for this to work in Chrome & IE9.
But these two only leave a space where the Applet should be.
I can even highlight it.
Are there things I have to add in my xhtml? Or maybe something in the Applet?
I found enough online about why Applets might not work, but nothing about why Firefox only.
As Andrew Thompson said, I need to use deployJava.js.
You can find it in this Oracle tutorial.
This tutorial describes in detail every step neccessary.
Now my Applet works on all three browsers (FF, Chrome, IE9) like a charm.
Thanks!

Validate JSF tags/attributes in Eclipse Indigo

In Eclipse Indigo (for Java EE Developers, JBoss Tools are installed) I
created new "Dynamic Web Project",
enabled the JSF v 2.0 from Project Facets and
added xhtml file whose content is below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head>
<body>
<h:messages layout="table" />
</body>
</html>
Now I want to see validation warnings / errors when I change the JSF tag or its attribute to some invalid value like these:
Invalid tag <h:barfoo layout="table" />
Invalid attribute <h:messages barfoo="table" />
Invalid attribute val <h:messages layout="barfoo" />
Currently I cannot see any warnings for all 3 ones in Eclipse. How can I validate the page?
The autocompletion (Ctrl+Space) is just working fine for tags and attributes. JBoss AS 7.1.1 is registered to Eclipse.
I've also had this problem a couple of times. You need to understand that an xhtml page can contain anything, plain text, JavaScript, html tags as well as lots of other types of tags. now the h: prefix is meant to indicate jsf tags, but remember you can also create custom tags that extend the h: prefix. So even though the tags are not available at the default namespace. eclipse won't warn you, however it will fail at runtime. you will get validation warnings if your xml is not well formed, but that's about it. That's one of the downsides of xml being so malleable.

What are Facelets and how is it related to JSF?

Am farely new to JSF and I get easily confused between JSF and Facelets when I read tutorials...
What are Facelets ?..Is JSF & Facelets the same ?...
How is Facelets different from JSTL ?
Facelets is a powerful but lightweight page declaration language that is used to build JavaServer Faces views using HTML style templates and to build component trees. Facelets features include the following:
·Use of XHTML for creating web pages
·Support for Facelets tag libraries in addition to JavaServer Faces and JSTL tag libraries
·Support for the Expression Language (EL)
·Templating for components and pages
Basically, Facelets allows you to add template tag libraries (XML documents) that are useful for adding UI controls in html pages, if you work with JSF. this declaration is an example of Facelets:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<!-- look at the xml library 'import' -->
<body>
<h:form>
<h:outputText value="Welcome, #{loggedInUser.name}" disabled="#{empty loggedInUser}" />
<h:inputText value="#{bean.property}" />
<!-- look at this tags, the special mark 'h:outputText'... -->
<h:commandButton value="OK" action="#{bean.doSomething}" />
</h:form>
</body>
</html>
In conclusion, Facelets provides the tools (template tag libraries) for UI controls and JSF allows the communication of this controls with back-beans.
http://en.wikipedia.org/wiki/Facelets
http://docs.oracle.com/javaee/6/tutorial/doc/gijtu.html

Is there a way to run a JSF page without building the whole project?

Is there a way to just run the one page so that I can see the generated html (and css) as it would look to the user even if it is essentially non-functional? Standalone JSF page as it were. I want to review how I am setting up forms to see if they make sense form a user standpoint before actually coding for the form's fields. I'm using maven and netbeans but not sure if the latter is relevant.
If you're using JSF2 Facelets, then you can just design your forms with plain HTML and use the jsfc attribute to specify the respective JSF component which should be used during JSF runtime. E.g.
<form jsfc="h:form">
<label jsfc="h:outputLabel" for="input1" />
<input type="text" jsfc="h:inputText" id="input1" value="#{bean.input1}" required="true" />
<span jsfc="h:message" for="input1" />
<input type="submit" jsfc="h:commandButton" value="Submit" action="#{bean.submit}" />
</form>
Reading the Facelets <ui:xxx> taglib documentation should also give some insights. E.g.
<span jsfc="ui:remove">
This is present during design time, but is removed during JSF runtime.
</span>
<div jsfc="ui:repeat" value="#{bean.items}" var="item">#{item}</div>
<table>
<tr jsfc="ui:repeat" value="#{bean.items}" var="item">
<td>#{item.id}</td>
<td>#{item.name}</td>
</tr>
</table>
And the fact that you can use <ui:composition> to specify the start and end of a Facelet composition (e.g. an include file or a tag file). Any content outside will be disregarded during runtime, but you can still put some HTML around during designtime so that you can easily preview complete designs in which the include file or tag file is supposed to be part of.
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<head>
...
</head>
<body>
...
<ui:composition>
Here you can design content of include file or
tag file as if it's part of the whole design.
</ui:composition>
...
</body>
</html>
This all allows you to preview HTML/CSS designs without needing a JSF runtime.
JBoss Tools for Eclipse have rudimentary support for JSF-tags in their visual editor.
I played briefly with it, but it did not support our legacy pages fully, so I left it at that. It may work better when starting with a blank page.
You can not execute a JSF page directly without deploying the built application. You have to deploy it, and only then will you be able to display executed the page.

For some reason JSP documents output XML instead of HTML

OK, so I am trying to set up a simple JSF application. I'm using NetBeans 6.8, Glassfishv3 and Maven2. I made a JSP document like so:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<f:view>
<head>
<title><h:outputText value="#{Welcome.title}"/></title>
</head>
<body>
<h:outputText value="Welcome"/>
</body>
</f:view>
</html>
Problem is, if I navigate to this page (http://myHost/myApp/faces/welcome.jspx), it is returned as an XML document, but with the ${Welcome.title} value populated:
<?xml version="1.0" encoding="UTF-8"?>
<html><head><title>Gymix - Welcome</title></head><body>Welcome</body></html>
In Internet Explorer this looks like I would have opened an XML document. In Google Chrome the title is printed next to the text Welcome and instead of the title the URL to the page is printed on the tab.
If I change the JSP document to a plain JSP page (taglibs instead of xmlns and so on) it works and I get a proper page returned. Any ideas on what's wrong? Thanks!
Edit: sadly none of the quick fixes fixed this, so I'll look into this more. BTW, my pom.xml has jsf-api and jsf-impl dependencies with the version for both set to 1.2_14
Aside from the fact that you need to set the proper doctype and content type so that the browser knows what to do with the page, you also should get rid of the old fashioned jspx format and use xhtml format to get the most benefit of Java EE 6-shipped JSF 2.0 and Facelets.
The given code should be changed to:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>#{welcome.title}</title>
</h:head>
<h:body>
Welcome
</h:body>
</html>
Note that the doctype is included and that JSF 2.0 / Facelets will automatically take care about the right content type with help of the <h:head> component. Also note the absence of the <f:view> tag, this isn't needed anymore in Facelets.
You probably also need to reconfigure your webapp to make use of the full powers of JSF 2.0 and Facelets. To learn more about JSF 2.0 and Facelets, I strongly recommend to go through the Java EE 6 tutorial part II chapters 4-9.
Good luck.
Update: as per the comment of bobince: I would add an important note; it is true that the XML declaration (the first line) would mess the rendering mode of some webbrowsers (also see the site behind the doctype link here above), but that's certainly not an issue here. Facelets removes the XML declaration during generating the HTML of the page. The XML declaration is simply there because Facelets needs to parse the page using a XML based tool first. We're talking about a component based MVC framework and XML based templating technology, not about a plain vanilla HTML page ;)
I think you need to put in a valid doctype.
This would go below your xml declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
You have to tell the browser what you're sending. I'm not exactly sure of how to do it inside a JSP though, so you'll have to figure out yourself or wait until someone more knowledgeable than me tells you.
You have to send the Content-Type HTTP header indicating your file is a text/html; charset=UTF-8.
Content-Type: text/html, charset=UTF-8

Categories

Resources