Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mouse event issue in primefaces 4.0

 
Sarah Labonne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am developing a java web application using primefaces 4.0 and jsf 2.0. i have a text label and it's textbox. when user is in edit mode, and want to modify the value of a particular textbox, the old value of the textbox should be displayed on the right side while the user is entering the new value in the textbox. so i add an output text which rendered false on load. i want to trigger this output text(id="test") when the user click in the textbox(id="customer_customername"). so rendered should be change to equal. anyone can tell me how to do this? in my backend i have an interface with its implementation , dao and service.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Delete the onclick from the inputText control and sensitize the ajax sub-element to 'event="click"'. That will allow you to fire an AJAX listener method in your backing bean which should copy the current value of "CustomerComponent.customer.customername" to a display property such as "CustomerComponent.oldCustomername" and set the "visible" property true. As part of the AJAX re-rendering processs, the the outputText component "test" will become visible and render the value of CustomerComponent.oldCustomername.

As a side note, backing beans are instances, not classes, so you really shouldn't start its name with an upper-case letter. A number of mechanisms (including the annotation processors plus many IDEs) make assumptions and take actions based on the assumed proper use of Java upper/lowercase conventions.
 
Sarah Labonne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok how do i trigger the output text upon event=click ?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what the ajax event="click" and listener method is for.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic