0

is there a way to get the word the mouse is over on by using AJAX on JSF 2.0 (which even works on outputText component)?

My goal is to store that word on a bean variable (let's say #{bean.selectedWord}) to use for further operations.

Up to now I'm only able to get the entire value of the inputText element... I was wondering if I had to use jQuery too.

page.xhtml

     <h:inputText id = "myIinput" value="this is a test">
        <f:ajax event="mouseover" render="myOutput" execute="myInput"
                listener="#{bean.ajaxFunction}"/>
     </h:inputText>
     <h:outputText id ="myOutput" value="#{bean.selectedWord}" />

bean.java

String selectedWord;

  public void ajaxFunction(AjaxBehaviorEvent event) {
    UIComponent uic = event.getComponent();
    String output = (String) uic.getAttributes().get("value");
    myOutput = output ;
  }

  public String getSelectedWord(){
    return selectedWord
  }
P-79
  • 1
  • 1

1 Answers1

0

Plain JSF nor any of the component suites I know of has a component for this. So effectively you need to break down your problem in two:

Combine the two and you have your solution. But don't forget to add a delay in the hover so not every qucik hover isemd, just when the user pauses.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47