Hi
I am developing Web POS (Point of sales) using Icarus Theme and a code bar reader "HoneyWell".
I am trying to set focus trough back bean to an inputnumber component once code bar is read. But never control get focus.
Elements used:
- Primefaces 6.1 Community
- Primefaces Icarus Theme.
- HoneyWell Voyager 9520 codebar scanner
-Tomcat 9 M21
- Browser: Chrome 59.0.3071.115 (Build oficial) (64 bits) / FireFox 54.0.1 (64-bits) / Microsoft Edge
Source code resume
1. xhtml
1.1 <h:form id="frmColMan" >
(note: I used <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> -as also other jquery versions- changing focus works!, but
some primefaces components like p:selectOneMenu, p:calendar got malfunctions or unexpected behavior)
1.2 <p:focus id="focusID" for="#{vwCodeBar.focusProperty}" /> (note: component recomended for setting focus)
1.3
<div class="ui-g-6 ui-lg-6">
<p:inputText id="itBarCode" value="#{vwCodeBar.strCodeBar}" placeholder="Bar code input" tabindex="2"
onkeydown="enterToTab(event);"
onkeypress="if (event.keyCode == 13) { onchange(); return false; }">
<p:ajax event="change"
listener="#{vwCodeBar.codeBarBreakDown}"
update="valuePay, focusID" />
</p:inputText>
</div>
(note: this code piece for reading bar code input)
1.4
<script>
trigger: function focusField(){
jQuery( document ).ready(function( $ ) {
$('#valuePay').focus('init');
});
$('#valuePay').focus();
document.getElementById("frmColMan:valuePay").focus();
this.focus();
return false;
}
(also used in different several times, but without results
function focusField(){
document.getElementById('frmColMan:valuePay').focus();
}
function focusField(){
$("#frmColMan\\:valuePay").focus();
}
)
function enterToTab(event){
if (event.which === 13) {
event.keyCode = 9;
$("#frmColMan\\:valuePay").get(0).focus();
$("#valorPagar").focus();
$('input[name="valuePay"]').focus();
return false;
}
}
</script>
2. Java Back bean
@ManagedBean(name="vwCodeBar")
@ViewScoped
public class CodeBar extends Exception {
public CodeBar() {
focusProperty = "itBarCode"; //set focus ok!
}
//Getting code bar configuration
public void codeBarBreakDown(AjaxBehaviorEvent event){
.
.
.
strValue = strCodeBar.substring(posIni , posFin);
valueToPay = transformToPay(strValue);
RequestContext.getCurrentInstance().update("frmColMan:valuePay"); //does not work or refresh component focus
focusProperty = "valuePay"; //does not work or refresh component focus
}
}
As you can see , Javascript and Primefaces is used in order to set focus from backing bean programmatically. But without any success.
Change focus is required for work flow process.
Thanks in advance
Primefaces Icarus inputtext setting focus from bean
Forum rules
Please note that response time for technical support is within 3-5 business days.
Please note that response time for technical support is within 3-5 business days.
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
This isn't an Icarus Layout or Theme issue. Please use core forum; viewforum.php?f=3
Github Profile: https://github.com/mertsincan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 8 guests