This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Trying to bind inputText fields from an a4j:repeat tag to java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Trying to bind inputText fields from an a4j:repeat tag to java code" Watch "Trying to bind inputText fields from an a4j:repeat tag to java code" New topic
Author

Trying to bind inputText fields from an a4j:repeat tag to java code

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Here is the code snippet from my jsf page:

The value is "deviceList" which is a List full of Device Objects. So this can display anywhere from 0-10 devices.

I need to be able to edit any or all of the inputText fields to change the device.name value. I'm really not sure how to do this though.

Here is how I would do so if there were only one device, and if I were not using a4j:repeat tag.

Here would be the jsf page:



Much easier to edit in the java code, because it is binding that device name to an actual variable in my updateAllBean. But in the first bit of code I am binding that to one of the values in the deviceList List that is a variable in the updateAllBean. So essentially I am trying to edit Objects in a List rather than individual variables.
Here is what the java code would look like if I used this second version of the jsf page:



But that above java code is not going to work when I change my jsf page to the a4j:repeat (which is what must be done so all devices are displayed, not just one device)

In that java code, lines 5 and 23 are going to be the problem. Line 5 refers to the deviceName variable and line 23 refers to the deviceId variable. However, in the a4j version of this page, those two variables do not exist, except indirectly. They exist in the Device class, and there is a List of Device Objects, but Im not sure how to make this work.

So lets say the first jsf code from above returns a page with two devices, like this:

DeviceId: Device1
Device Name: Device Name 1

DeviceId: Device2
Device Name: Device Name 2

The underlined fields represent inputText fields that can be edited. So let's say I want to change the name on device 1, but not device 2. I would re type the first text field to whatever name I want to change it to, but how am I going to let my java code know which one Im trying to change? Will it just know which device I am trying to change by which text field I edit?

Any tips would be great, I'm a bit lost on how to do this.


True wisdom is in knowing you know nothing - Socrates
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Thinking about it I may just make each device outputField a command Link. The user can then click on each device they want to edit.

Will only be able to do one at a time but it will solve this problem at least.

If there is another way to get it like I want it above please feel free to show me how though, I can always change it when Im not on a deadline.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trying to bind inputText fields from an a4j:repeat tag to java code
 
Similar Threads
Need to make empty text fields not pass null as the value, need them to just not pass anything
Need my rich:tree to be re loaded when I add a new entity to it
need nodes on rich:tree to not be auto selected, only selected when clicked on.
Is there java class to parse xml nodes?
Trying to figure out java code to bind to outputLinks generated from a4j:repeat tags