<p:growl id="growl" showDetail="true" showSummary="true" globalOnly="false"> <p:autoUpdate /> </p:growl> <p><p:inputText id="input" style="width:530px"/></p> <pe:codeScanner width="530" height="400" for="input"> <p:ajax event="codeScanned" listener="#{codeScannerController.onCodeScanned}"/> </pe:codeScanner>
@Named @ViewScoped public class CodeScannerController implements Serializable { public void onCodeScanned(final SelectEvent<Code> event) { final Code code = event.getObject(); FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_INFO, String.format("Scanned: %s (%s)", code.getValue(), code.getFormat()), null)); } }