I have a problem that I can't fix for a very long time. I can't use icefaces sliderEntry in my project, I do this:
pom:
<repository>
<id>snapshots</id>
<url>http://anonsvn.icefaces.org/repo/maven2/releases/</url>
</repository>
and more:
<dependency>
<scope>provided</scope>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>3.1.0</version>
</dependency>
in my xhtml:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough"
xmlns:ace="http://www.icefaces.org/icefaces/components"
>
so I call the slider:
<h:form>
<ace:sliderEntry />
</h:form>
But I don't see it on my page, the debugging tools also don't say anything useful. Maybe I ported something wrong?
UPD
I noticed that this element in the browser has the hidden type, why is this happening?
Use
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>4.3.0</version>
</dependency>
and be sure that all the icefaces libraries have a "compile" scope
You need also use <h:body> instead of default <body> tags
Related
This question already has answers here:
Submitting a form by pressing enter without a submit button
(20 answers)
Closed 1 year ago.
After deploy this code i go to browser and put some data in input field and press enter. It should add text to chips but it doesn't i don't have idea why plaease help.
xhtml code
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Chips</title>
</h:head>
<h:body>
Chips
<br/>
<h:form>
<h:panelGrid columns="2">
<p:outputLabel value="Add Color"/>
<p:chips />
<p:outputLabel for="display" value="Avaiable Colors"/>
<p:chips id="display" value="#{colors.colors}"/>
</h:panelGrid>
</h:form>
</h:body>
</html>
I use this java class for xhtml with use JSF and PrimeFaces.
#ViewScoped
#Data
#Named
public class Colors implements Serializable{
private List<String> colors;
#PostConstruct
public void init() {
colors = new ArrayList<>();
colors.add("Red");
colors.add("Blue");
colors.add("Green");
colors.add("Yellow");
colors.add("Orange");
colors.add("Purple");
}
}
This is my pom.xml file maybe here something is missing. Please help it's look everything fine.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.mz</groupId>
<artifactId>Primefaces-YtTutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jakarta.jakartaee-api.version>8.0.0</jakarta.jakartaee-api.version>
<microprofile.version>3.0</microprofile.version>
<mockito-core.version>3.1.0</mockito-core.version>
<junit-jupiter.version>5.5.0</junit-jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakarta.jakartaee-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>${microprofile.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>11.0.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>
<build>
<finalName>Primefaces-YtTutorial</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</project>
I add not visible commandButton and this start work corectly. But i hope someone will show me beter why to solve this issue or will point some bug in my code. I leave my solution here.
<h:form>
<h:panelGrid columns="2">
<p:outputLabel value="Add Color"/>
<p:chips/>
<p:outputLabel for="display" value="Avaiable Colors"/>
<p:chips id="display" value="#{colors.colors}"/>
</h:panelGrid>
<p:commandButton rendered="false"/>
</h:form>
I work with PrimeFaces 5.2.
These are my maven dependencies:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
</dependencies>
I have the XHTML:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<h:head />
<h:body>
<h:outputLabel>Name:</h:outputLabel>
<h:form>
<p:spinner />
</h:form>
</h:body>
</f:view>
</html>
The output screen is
How do I have to configure my project to see the spinner?
I think you should read the documentation for a spinner in Primefaces. Spinner is primarily used to increment/decrement the value of input text. You also need to create a bean defining the setter/getter for the values.
Do have a look https://www.primefaces.org/showcase/ui/input/spinner.xhtml
Just for reference:
<h:outputLabel for="basic" value="Basic Spinner: " />
<p:spinner id="basic" value="#{spinnerView.number1}" />
Hope it helps!!
I just tried to just copy-paste sample from PrimeFaces Showcase about Barcode.
Here is this code, and I get:
I just wanted to test it go get same effect as sample.
<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:pm="http://primefaces.org/mobile"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:panelGrid columns="2">
<h:outputText value="Postnet" />
<p:barcode value="0123456789" type="postnet"/>
<h:outputText value="QR" />
<p:barcode value="0123456789" type="qr"/>
</p:panelGrid>
</h:body>
Have you add barcode4j and qrgen library into your dependency?
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId>
<version>2.1</version>
</dependency>
**barcode4j 2.1 does not exist in maven central repository so manual installation is necessary for
maven users
you need to add a jar file to your repository to let primefaces understand the component much better. You can get the jar from here http://www.barcodelib.com/java_barcode/barcode_symbologies. That is the "barcode4j-light version 2.1"
This question already has an answer here:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output
(1 answer)
Closed 5 years ago.
I couldn't see neither primefaces nor html components in my page. I can see only "sdaf" string. What can be the problem? At index.xhtml page autocomplete works good I can see component names. There must be nothing wrong with libraries.
My index.xhtml file;
<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>
<h:button value="html button"> </h:button>
sdaf
<p:spinner />
</h:body>
</html>
my pom.xml file;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>5454</groupId>
<artifactId>45454</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>45454 Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>45454</finalName>
</build>
</project>
Try this code to see whether you can see inputtext box and a command button,
<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">
<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>Title Goes Here</title>
</f:facet>
</h:head>
<h:body>
<h:form>
<p:panel header="Send">
<p:inputText value="Hi"></p:inputText>
<p:commandButton value="Send" id="btnDisplay"/>
</p:panel>
</h:form>
</h:body>
</f:view>
</html>
Web.xml
You need to have the below lines in your web.xml file
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Problem could be your 'URL' if in your web.xml you have mapping:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>`
then you need to add 'faces' to your url. For example:
:http://localhost:8080/ABC/faces/pages/login.xhtml
The reason is because you have not rendered the requested api like jsf-impl to your pom.xml for reference check Primefaces-Maven-Example
Try to put your elements to show on page into the form tag:
<h:form>
<h:button value="html button"> </h:button>
sdaf
<p:spinner/>
</h:form>
I am a JSF beginner. I try to implement ICEfaces 3.0 component in Eclipse 4.2 (Juno). I had implemented & run it using Apache Tomcat 7.0. It showing the following error in window:
Cannot add the same component twice
In console bar it shows as :
javax.faces.FacesException: Cannot add the same component twice: v8z4ho2-retrieve-update
My JSF Code
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ice="http://www.icesoft.com/icefaces/component" >
<h:head>
<title>Chart</title>
<link rel="stylesheet" type="text/css" href="./xmlhttp/css/rime/rime.css"/>
</h:head>
<h:body styleClass="ice-skin-rime">
<h:form id="canvasForm">
<ace:chart id="chart" animated="false" value="#{chartBean.barData}"
stackSeries="false" defaultAxesConfig="#{chartBean.barDemoDefaultAxis}"
xAxis="#{chartBean.barDemoXAxis}" yAxis="#{chartBean.barDemoYAxis}"
legend="true" legendPlacement="OUTSIDE_GRID" highlighter="true"
highlighterLocation="N" highlighterShowMarker="false"
highlighterBringSeriesToFront="true"
widgetVar="barChart" />
</h:form>
</h:body>
</html>
How to rectify this error? Help me out.
In ICEFaces forum I've found many people with this problem. If you are using Tomcat 7.0.42, try Tomcat 7.0.41 instead and see if it works. Also check if you have icefaces jar duplicated (or icefaces.jar and icefaces-ee.jar) in the same classpath. The link to the post is:
http://www.icesoft.org/JForum/posts/list/22121.page#sthash.qxEkXX1Q.dpbs
Fixed by reverting icefaces version from 3.3.0 to 3.0.1:
<!-- Ices Dependencies -->
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-compat</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.icepush</groupId>
<artifactId>icepush</artifactId>
<version>3.1.0</version>
</dependency>