This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Create JSF Html Element through javascript  RSS feed

 
Dushyant Janbdnhu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I want Create JSF Html Element like
<h:inputText value="#{myBean.beanAttr}" >
through javascript by some onclick(Button) event this is very simple in
html& java script

Can any budy has an idea
 
Sid Murrey
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dushyant Janbdnhu:
Hi
I want Create JSF Html Element like
<h:inputText value="#{myBean.beanAttr}" >
through javascript by some onclick(Button) event this is very simple in
html& java script

Can any budy has an idea


I can not haz an idea, but I know what could be a problem:

JSP pages containing JSF components are translated to HTML by the application server. When you generate a JSF element via JavaScript, it won't be interpreted at all!
 
Tim Holloway
Bartender
Posts: 18720
72
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, while HTML clients understand HTML and thus it's easy to insert HTML elements into the DOM, HTML clients do not understand JSF and therefore client-side JavaScript cannot insert JSF into rendered pages. There's nothing on the client side to properly interpret the JSF.

JSF is translated to HTML on the server by the JSF HTML renderKit and it is this translated HTML that goes to the browser.
 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you would like to use AJAX instead (I like a4j), then you can easily have your button call something in a backing bean which changes a rendered status. Or, if you have a binding to a panel or other container, you can create the HTML components dynamically and add them as children to the panel.

Another option would be to do any of these things without using AJAX...but then you have the ugly page refresh, of course.

Hope this helps
~Zack
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!