• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Puzzle with <h:head> tag

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struggling with an application where a form with <h:inputtext> is populated from the selected row in a <h:datatable>.
After a good afternoon of hair pulling, I decided to reduce my application to a simple test case, so I can consult others.

File test.xhtml:


File TestBean.java:


I expect the h:inputText to be filled whenever the user selects a row in the h:dataTable, but this is not happening.
However, I discovered the problem is solved by removing the <h:head><title>Testing</title></h:head>, which makes absolutely no sense to me.

I must be missing some triviality, but have no clue as to how to approach this, so any help is appreciated.
 
Saloon Keeper
Posts: 28468
210
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
Actually, in JSF2, if you don't use the JSF h:head and h:body tags, JSF will not put the right supporting code and elements in the right places on the generated HTML and the page should not work properly.

Superficially, things look OK with what you're doing, but I do have one suspicion.

You have no "id=" property on your h:form. It's good practice to always give id's to container elements such as forms, dataTables, panelGrids, and so forth. If you do not, JSF will synthesize unpredictable IDs for those containers and use those IDs to create the actual HTML element IDs.

In your particular case, I think the problem is that you're referencing an element from within a container (the dataTable)  that is external to that container, even though both the container (datatable) and the referenced control (inputText) are part of the same form. If you you give the form an ID and used the form/inputTextID concatenation as the attribute value for the "render=" on the ajax element, that may fix things.

Which brings me to another point. Not only should you give container elements id attributes, you should also give ids to input controls. Even if you don't actually reference them, it makes it easier to debug views if you have to resort to the "View Page Source" debugging option.

 
Izak van Langevelde
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:In your particular case, I think the problem is that you're referencing an element from within a container (the dataTable)  that is external to that container, even though both the container (datatable) and the referenced control (inputText) are part of the same form. If you you give the form an ID and used the form/inputTextID concatenation as the attribute value for the "render=" on the ajax element, that may fix things.



That fixes things, indeed! I know about ids, but I left out most of the details to keep my code short.
The puzzle of why dropping the head section solves things, remains, though.

Anyways, thanks for sorting me out!
 
Run away! Run away! Here, take this tiny ad with you:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic