5

I am using primefaces to develop a web app.I am trying to show the bar code on mhe webpage.All coders are shown except the QR code.I have read that two jar files are required for this sample

  • barcode4j: 2.1
  • qrgen: 1.4

I have added these jar files in the lib folder & try running it.In this way i get 404 error when i add qrgen in lib folder.

I tried doing it using maven i added the depedency as follows:

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

but i get error for second dependency so i copied the barcode4j in lib folder but i can't print the QR code.please help me out.

code for xhtml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>login</title>
    </h:head>
    <h:body>

   <p:panelGrid columns="2">
    <h:outputText value="Interleaved 2 of 5" />
    <p:barcode value="0123456789" type="int2of5" />

    <h:outputText value="Codabar" />
    <p:barcode value="0123456789" type="codabar"/>

    <h:outputText value="Code39" />
    <p:barcode value="0123456789" type="code39" />

    <h:outputText value="Code128" />
    <p:barcode value="0123456789" type="code128"/>

    <h:outputText value="EAN-8" />
    <p:barcode value="20123451" type="ean8"/>

    <h:outputText value="EAN-13" />
    <p:barcode value="0123456789012" type="ean13"/>

    <h:outputText value="UPC-A (PNG)" />
    <p:barcode value="01234567895" type="upca" format="png"/>

    <h:outputText value="UPC-E (Vertical)" />
    <p:barcode value="01234133" type="upce" orientation="90"/>

    <h:outputText value="PDF417" />
    <p:barcode value="0123456789" type="pdf417"/>

    <h:outputText value="DataMatrix" />
    <p:barcode value="0123456789" type="datamatrix"/>

    <h:outputText value="Postnet" />
    <p:barcode value="0123456789" type="postnet"/>

    <h:outputText value="QR" />
    <p:barcode value="0123456789" type="qr"/>
</p:panelGrid>
    </h:body> 

</html>

pom.xml

<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>com.prime</groupId>
    <artifactId>primedemop</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>primefaces</name>
    <dependencies>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.1</version>
        </dependency>
          <dependency>
        <groupId>net.glxn</groupId>
        <artifactId>qrgen</artifactId>
        <version>1.4</version>
    </dependency>


    </dependencies>![smaple][2]
</project>
Ankit Sharma
  • 147
  • 1
  • 9
  • [This question](http://stackoverflow.com/questions/29993696/maven-depedency-not-working-in-primefaces/) specifically resolves the issue around Maven dependencies. What you need to do is 1) Prove that your source code compiles while using libraries from the QR code package and 2) Show us in your source code where you attempt to use these libraries. What we're seeing here doesn't appear to be a problem with the dependency management, but something else. Without the full picture, nobody can help you. – Ryan J May 02 '15 at 20:34

1 Answers1

3

I guess you're doing all ok.But you missed on one thing.The qrgen-1.4 you are using are further having dependencies as zxing-core-2.0 & zxing-javase trying including these two jar files into your build path these might work well.

TechChain
  • 8,404
  • 29
  • 103
  • 228