• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic