QR Code

UI Components for JSF
Post Reply
stefanphl
Posts: 4
Joined: 24 Aug 2017, 01:50

15 Nov 2017, 23:26

Hi, everyone !

I am new at Primefaces and I am trying to use the QR Code Generator from <p:barcode> component. I am having trouble generating them. I am not sure which .jar files should I include in my project path. I have tried with barcode4j-light and qrgen, but then the server won't start. Then I included zxing-core-2.0 and zxing-javase, but also without luck at the end. Am I missing something? On showcases there is nothing about dependencies.

Best regards,

Stefan Puhalo

Jan Eckert
Posts: 84
Joined: 11 Sep 2014, 10:13
Location: Brussels, Belgium

16 Nov 2017, 11:34

Do you use a build tool? Something like maven or anything else?
Primefaces 6.1+
Wildfly 11

stefanphl
Posts: 4
Joined: 24 Aug 2017, 01:50

16 Nov 2017, 11:50

I am not using maven, I just copy jar files in WEB-INF/lib. I build project in the IDE (Intellij). Everything works fine, except <p:barcode>.

Jan Eckert
Posts: 84
Joined: 11 Sep 2014, 10:13
Location: Brussels, Belgium

16 Nov 2017, 11:57

Which version of Primefaces do you use *exactly*?
Primefaces 6.1+
Wildfly 11

stefanphl
Posts: 4
Joined: 24 Aug 2017, 01:50

16 Nov 2017, 12:06

Primefaces 6.1
I have in my path following primefaces jar files: primefaces-6.1.jar and primefaces-6.1-sources.jar.
I have itext-4.2.1 for data exporting. That also works fine.

Jan Eckert
Posts: 84
Joined: 11 Sep 2014, 10:13
Location: Brussels, Belgium

16 Nov 2017, 12:29

I see a conflict between what Maven does and what I see in the Primefaces User manual. Maven uses qrgen version 1.4 (as expected) but barcode4j-light in version 2.0 (not 2.1). Maybe because at the time of writing, version 2.1 was not available in the maven repository (it is meanwhile). There are also transitive dependencies that Maven sees, so I would suggest, you put the following libs on your classpath and try again:

Those marked down in the user manual. Not sure about barcode-light, whether to use 2.1 or 2.0

Code: Select all

<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> //try 2.0 as well maybe ....
</dependency>
transitive dependeny of barcode-light ... add only if it is not yet on your classpath

Code: Select all

<dependency>
	<groupId>xml-apis</groupId>
	<artifactId>xml-apis</artifactId>
	<version>1.3.04</version>
</dependency>
Transitive dependeny of qrgen ... add only if it is not yet on your classpath

Code: Select all

<dependency>
	<groupId>com.google.zxing</groupId>
	<artifactId>javase</artifactId>
	<version>3.0.0</version>
</dependency>

<dependency>
	<groupId>com.google.zxing</groupId>
	<artifactId>core</artifactId>
	<version>3.0.0</version>
</dependency>

Good luck and let me know!
Primefaces 6.1+
Wildfly 11

stefanphl
Posts: 4
Joined: 24 Aug 2017, 01:50

16 Nov 2017, 13:55

Thanks a lot. It finally works. I don't know why are the required dependencies not mentioned in the showcase...

Jan Eckert
Posts: 84
Joined: 11 Sep 2014, 10:13
Location: Brussels, Belgium

16 Nov 2017, 18:12

Actually, this is pretty normal. Each software vendor keeps a keen eye on their direct dependencies. This is what Primefaces did, they documented those two and they were done. Documenting dependencies of the dependencies is a tedious process because after each new release (of other groups!) you would need to check these foreign projects for removed/added dependencies. I'd rather see them directing their attention to PF issues than this kind of repetitive tasks.

I know that it might seem a bit frustrating for you but dependency management is a super-well understood (although not trivial) issue that can be automatically solved for 99% of all cases by using a build tool. If I was in a place to give you advice, I would tell you to get started with Maven (if you have some affinity with XML) or Gradle (a more modern approach) or another of these tools I am not as familiar with. It will get your skills as a Software Engineer to the next level.

Heads up and have fun with QR codes! :)
Primefaces 6.1+
Wildfly 11

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests