File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes [ICEfaces] Clearing one inputText form when changing radio button selected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "[ICEfaces] Clearing one inputText form when changing radio button selected" Watch "[ICEfaces] Clearing one inputText form when changing radio button selected" New topic
Author

[ICEfaces] Clearing one inputText form when changing radio button selected

Peter Fat
Greenhorn

Joined: Oct 18, 2010
Posts: 24
Hi!

I have a set of 3 radio buttons (A, B, and C). Like, A="1", B="2", and C="other value". When I select C, it renders a inputText box in front of it, so user can write a value of is choice.
The problem is: if the user writes a value on the box, and then changes to A or B, if he chooses C, the value will still be there, and I want for the form to be cleared, when the radio button is changed. How can I accomplish this?

Thanks
tirwit
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
When you say that the the text field is rendered how do mean "rendered"? With ajax (using what tag in what tag library?)? With normal page load? With javascript?

Why can't you use the same method you used to create the field to remove it as well?
Peter Fat
Greenhorn

Joined: Oct 18, 2010
Posts: 24


The radio buttons have the values:
A=1
B=2
C=-1

In the bean, the method to set the dateSelectedIndex also sets the "date" value, which is where the inputText tag will also store it's value. I'm new in this stuff, so have I answered your question?
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
So you use Icefaces. That is the most important thing you left out of your first message
How would we know what third party libraries you use. And for example when you talk about inputText of course everyone expects that you are talking about standard JSF tags and not some third party coded inputText.

So now someone who is familiar with Icefaces has a change to answer your question. I myself am not.

But some comments I can still make. Based on the partialSubmit argument you use AJAX to make the field visible? And you are saying that using the same ajax approach you can not hide the field? You said in your post above that you make the inputText visible BUT your code says instead that you make the panelGrid surrounding it (and not the field itself) visible. Is there a reason for that?
Peter Fat
Greenhorn

Joined: Oct 18, 2010
Posts: 24
Don't really know what's AJAX... I'm using ICEfaces, but still don't understand the whole functioning of what's behind it.

I can hide the field, the problem is, if I select option C, making the text box visible, and I input some value on it, if I then choose some other option, and then I choose option C again, when the box shos again, it will still have the value that I entered previously... But I want the text box to clear itself when I change the radio button.

I render the panelGrid and not the text box itself because there's also a outputText in that panelGrid, even thou I didn't write it down here. Does it make a big difference to render the panelGrid, instead of the inputText tag?
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
If you are not familiar with the term ajax and you want to develop web applications then I suggest to you that you learn that first. You may not need to understand it to solve this issue (or maybe you do) but you will run into more trouble in the future.
http://en.wikipedia.org/wiki/Ajax_%28programming%29

You could clear the field with javascript (by putting id attribute to your text field and firing the javascript using onchange attribute with your radiobutton group) if the value is only visible on your page. If the value has been sent to server that may not be enough but yet again I am not familiar with icefaces tags (I see that someone has changed the topic name to include the [ICEFaces] by the way!) so I do not know.

I will stop answering to this thread now and hope you will find answer to your problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [ICEfaces] Clearing one inputText form when changing radio button selected
 
Similar Threads
xforms UI question
How to create a compounded radio button?
JSP and Radio Buttons
html radio button add to database
cursor defaults to inputtext box