• 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

JSF and Javascript why id elements have a strange names

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody:

Unfortunately I still have problems using Richfaces or Icefaces in my JSF application so I think to use plain Javascript. But now I got a problem, I try to get the element but it doesn't work because it seems to me that the ids and names are changed. When I see the generated code in my browser it looks like this:



I have in my code:
So the question is why my code works well with HTML but not with JSF tags? Do you think is better using Dynamic Faces (JSF Ajax Extension)? To many options but I don't know what way to choose and my time is running out. They gave me an opportunity but need results!

Could you give a hand to a newbie JSF programmer? Thanks!
 
Ranch Hand
Posts: 99
MyEclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmm, I haven't played enough with JSF so I don't know if there is any way to clean the ids. What you could do without digging the Web is this:

Hope you get the idea. I'd recommend changing indexOf to a regexp to specify that there is nothing after the id parameter (with indexOf you can get more than one element if their ids is like "myEl01one", "myEl01two"). And of course since with this code you'll through every element on the page it can be slow if you use it with high frequency in you algorithm.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok...I got your idea. I'll do my homework filtering the ids.

You'll hear from me soon.

Thanks a lot for your help, Akaine.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found one way to solve my problem in Adding Ajax to JavaServer Faces Technology With Dynamic Faces

The solution is:

1) Add the JSF Extension(Ajax) to my project

2) in the web.xml add
3) Add the followint to my page JSF page:
4) and finally in the form tag:


This new attribute in JavaServer Faces 1.2 technology advises the JavaServer Faces runtime to not prepend any naming container IDs to your component IDs within the form. The result is that the IDs you type in the markup are the actual ones that appear in the page.

Taken from the article i mentioned before and it works!
 
Akaine Harga
Ranch Hand
Posts: 99
MyEclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, will have in mind... =)
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you supply your own id to the form???

h:form id="someform"

next is the result............
h:input id="someform:firstinput"
 
Akaine Harga
Ranch Hand
Posts: 99
MyEclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Samuel March wrote:Did you supply your own id to the form???
h:form id="someform"
next is the result............
h:input id="someform:firstinput"

Hmm, I always had the ids this way and I always supplied the form id. So I don't know what's wrong or if there is anything wrong at all. JSF and especially Richfaces generate many elements to display one simple field and almost each elements has its id generated.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

You're right... I supplied an id to the form and then I called it the way you said (formId:elementId) and it works as well. The first time I did it I made a mistake given a no unique id to the form...now I realized about that. Anyway with JSF Extension(Ajax) allow me to add Ajax functionality to JSF's components.

A new task has arised ... How to use Dynamic Faces in my project...too many doubts . I'm on my way...

Thanks Samuel and Akaine for helping me.

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The magic word is "naming container".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic