3 Replies Latest reply on Jan 4, 2011 3:14 AM by Stefano Zaccaria

    [dynamic suggestionbox] setFetchValue problem

    Jordi Teterissa Newbie

      Hi, i'm building a dynamic suggestionbox. So far so good, but there's one thing which got me stuck.

      For the outputtext in the colums of the sug.box I use:

      ve = fc.getApplication().getExpressionFactory().createValueExpression(fc.getELContext(), "#{result.studentNumber}",String.class);
      labelColumn1.setValueExpression("value", ve);
      
      ve = fc.getApplication().getExpressionFactory().createValueExpression(fc.getELContext(), "#{result.studentName}",String.class);
      labelColumn2.setValueExpression("value", ve);
      


      this works fine! However, since I got 2 columns, I only want text from one of the columns in my inputfield when I click on a
      row in the sug.box.

      So I though:

      ve = fc.getApplication().getExpressionFactory().createValueExpression(fc.getELContext(), "#{result.studentNumber}",String.class);
      suggestionBox.setFetchValue(ve);
      


      Too bad, this doesn't work :( As a result I get in the inputfield: 'ValueExpression[#{result.studentNumber}]', which is just
      a String.

      So i tried adding a a4j:support component which called the setStudentNumber method:

      ValueExpression target = fc.getApplication().getExpressionFactory().createValueExpression(fc.getELContext(), "#{bean.studentNumber}", String.class);
      
      ValueExpression propertyValue = fc.getApplication().getExpressionFactory().createValueExpression(fc.getELContext(),"#{result.studentNumber}", String.class);
      
      SetPropertyActionListenerImpl listener = new SetPropertyActionListenerImpl(target,propertyValue);
      a4jSupportComponent.addActionListener(listener);
      


      When I clicked on a row in the sug.box, it got in the setStudentNumber method. After this, the inputtext should be rerendered (so that the new studentnumber was going to be fetched), Too bad2, this also didn't work!

      I hope someone can tell me what i'm doing wrong...and i would really appreciate a solution or just suggestions.

      Thnx in advance!