• 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
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

javascript in jsf

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am very new to jsf.i am trying to assign some value to output text id from java script function. that output text is in one of the row of data table. but it is not happening.that output text value is not changing.can any body sugest me that wheather it is possible or not.

and another one is i need to change the color of some out put text value from onclick javascript function. in normal html i can do this thing by using some span tags.i need to change the style of output text value from javascript function.can any body suggest me that how can i do my requirment in jsf.

Thanks in advance.

Thanks & regards
Naresh
 
Saloon Keeper
Posts: 28807
212
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
I can't answser your first question, but you can probably set the color of an outputText tag by giving it an "id=" attribute and setting the color using that ID as a target. If not, another, somewhat messier possibility is to use "verbatim" JSF tags to wrap HTML span tags and target the span.

JSF tags are more function- and less display-oriented, often resulting in multiple or even variable sets of HTML output from a single JSF tag, which is why sometimes a more sophisticated approach is needed.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the first one ---- Yes its very much possible get the object and set the text as innerHtml like document.getElementById("").innerHTML = "hi".

Is this what you are looking for or I am not in right track ---!! let me know
 
Anirban Mandal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK sorry i missed the datatable part--- are you tryingto set the text in any event or on what ?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you must keep in mind how JSF component Ids are generated

all jsf components follow a naming pattern for identification, the patterns is: name of the form (two dots) name of a container (two dots) number of row (if you are using a datatable plus two dots) and keep moving on until the id of component. lets see:


The generate html of myInput will be:


if you have a panelGrid



The generate html of myInput will be: <input type="text" id="myForm:myGrid:myInput" />
Ps.: If myGryd was a parent of "myForm", so the id would be: myGrid:myForm:myInput

finally, if you use a dataTable


you input ID will be, for each row:
myForm:myTable:X:myInput -> where X is the number of the row, if the dataTable iterates 5 times, so the id of the inputs will be:
myForm:myTable:0:myInput
myForm:myTable:1:myInput
myForm:myTable:2:myInput
myForm:myTable:3:myInput
myForm:myTable:4:myInput


I hope you've understood my explanation :P

Ps.: If you want to access a component by javascript, just use DOM and be happy ;D
document.getElementById( 'myForm:myTable:0:myInput' ).value = "WE ROCKS";
 
Nareshkumar Kapilavai
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your valuble suggetions.
but here i am able to assign the value to input text.but in case of output text i am not able to assign the value.if i assign the value to input text id the modification is haapeening. but if i am trying to assign the value to out put text id it is not happening.
eventhow my Scenario in dataTable.. i am putting the button for every row. so when i clicking on the button that particular row values it is taking.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An inputText value can be submitted to the server. An outputText value is for display only. If you change that on the client side, the server side won't know anything about it.
 
Let me tell you a story about a man named Jed. He made this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic