In JSF2, this is a straight-up AJAX function. How you do it in JSF1 depends on what resources you have. If the app is engineered with RichFaces, PrimeFaces, or one of the other AJAX-supporting extension tagsets, it's also very easy. If not, then things get more challenging.
Here's how the AJAX-based solution works:
1. You assign an AJAX handler to the barcode input control. When a value is entered into that control, the AJAX client fires. It submits a request to the webapp server. This is typically a partial form request.
2. The AJAX event listener method on the server operates according to the standard JSF lifecyle, which means that the barcode value property in the backing bean will have been updated from the request by JSF automatically.
3. Therefore, the AJAX event listener method can lookup that barcode in the database and update the backing bean's property for the descriptive text with the result. You can also, of course, update other properties as well, in case you want to display
unit price, quantity on hand, or whatever.
4. When the AJAX event listener completes, JSF's "render response" lifecycle phase posts the updated backing bean properties back to the user's webpage. And that's all there is.
You can do all of the above without AJAX, but in that case, you'd have to submit the entire form and the entire webpage would be updated. Which is basic page operation.