Hi all.
I have recently started with
JSF (using MyFaces 1.2 and Trinidad) and knocked up a quick demonstration of a search, PPR, downloading files, saving results to CSV etc. Nothing fancy but it works and I was very impressed with how easy it was to do. I am just struggling with is a few very basic UI things, I've googled until I've boggled and still not found the answers. These are so simple, you'll probably laugh. No, really. You will.
1) How to "clear" an already empty required control
I have a combo ("cboProject" in the code below) and it is required. Eventually there will be many more controls, so I provided a button to clear the values and that's where I hit the problem. If the value is already empty, I get the default "You must enter a value" error message when I click on "Clear" because of the submit. I want to "Clear" to always clear the values on the UI, I am not concerned about validation when this is clicked but I cna't figure out how to do this. Is it a case of having to write some custom javascript to crawl the DOM and set all the inputs to null?
2) Pushing a value from one control to another
I have to have a text box and a combo ("txtProject" and "cboProject" below). If the user enters a value into the text box, the combo should show the corresponding item. If the user selects a value in the combo, the text box should update to show the stored value. To do this I have written some custom javascript (the "pushValueTo" function mentioned in the code below), but I am sure there has to be a better JSF way.
Due to the planned number of controls and volume of data, I'd like to avoid round-trips to the server and handle it all on the client (IE6) if possible.
Thanks for any helps/tips/advice.
rS