-
1. Re: <rich:suggestionbox problem
harut Mar 22, 2010 3:46 AM (in response to eugenbesel)Hi Eugene,
You can place a4:support inside inputTexts and place a4j:actionparam into a4j:support... something like this:
<h:inputText value="AAAAAAA"
id="INPUT_ID">
<a4j:support event="onkeyup">
<a4j:actionparam name="inputIdForSugBox" value="INPUT_ID"
assignTo="#{myBean.inputId}"/>
</a4j:support>
</h:inputText>Where assignTo="#{myBean.inputId}" -- inputId is a String property of your Bean class (private String inputId;).
So now "inputId" will have id of the input in which some text has been entered for sugestion-box...
-
2. Re: <rich:suggestionbox problem
eugenbesel Mar 22, 2010 5:25 AM (in response to harut)hello Harut,
that was my first idea too. but it didnt work. I think that the action for suggestionBox is called before a4j:support event is called. The attribute I setted in actionparam was null in my BBean.
<h:inputText value="#{capitalsBean.capital}" id="text" />
<rich:suggestionbox id="suggestionBoxId"suggestionAction="#{myBean.autocomplete}" var="result">
<a4j:support event="onkeyup">
<a4j:actionparam name="inputIdForSugBox" value="INPUT_ID"
assignTo="#{myBean.inputId}"/>
</a4j:support><h:outputText value="Border" />
</rich:suggestionbox>
</h:inputText>
perhaps I did something wrong??
-
3. Re: <rich:suggestionbox problem
ilya_shaikovsky Mar 22, 2010 5:26 AM (in response to harut)looks not really optimal. his request for suggestions also pointed to onkyup. So it will sees just stops working or will send two concurrent requests.
-
4. Re: <rich:suggestionbox problem
ilya_shaikovsky Mar 22, 2010 5:29 AM (in response to eugenbesel)remove support and use parameter simply nested to suggestionBox.
-
5. Re: <rich:suggestionbox problem
ilya_shaikovsky Mar 22, 2010 5:33 AM (in response to eugenbesel)simple test which works for me:
<h:panelGrid columns="2" columnClasses="sb_test_column1,sb_test_column2" width="100%"> <h:inputText value="#{capitalsBean.capital}" id="text" /> <rich:suggestionbox id="suggestionBoxId" for="text" tokens=",[]" suggestionAction="#{capitalsBean.autocomplete}" var="result" fetchValue="#{result.name}" rows="#{suggestionBox.intRows}" reRender="out"> <f:param name="sbid" value="sbid"/> <h:column> <h:graphicImage value="#{result.stateFlag}" /> </h:column> <h:column> <h:outputText value="#{result.name}" /> </h:column> <h:column> <h:outputText value="#{result.state}" style="font-style:italic" /> </h:column> </rich:suggestionbox> <h:outputText id="out" value="#{userBean.name}"/> </h:panelGrid>
and
public List<Capital> autocomplete(Object suggest) { System.out.println(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("sbid"));
-
6. Re: <rich:suggestionbox problem
eugenbesel Mar 22, 2010 7:19 AM (in response to ilya_shaikovsky)hello Ilja,
thank you for your advice. I will test this solution.
thank you.
wbr
Eugene
-
7. Re: <rich:suggestionbox problem
eugenbesel Mar 22, 2010 7:48 AM (in response to ilya_shaikovsky)hello Ilja,
I would like to use suggestionBox for InputField, which should use as Filter.
So when I chose some value from suggestionBox, some actionBean Method should be called.
Can I use a4j:support event="onblur" with suggestionBox?
suggestionBox has a parameters:
usingSuggestObjects="true"
onobjectchange="processObjectsChange(suggestion)">but on this place the JavaScript function is called.
which parameter should I use for calling of the method from Bean??
-
8. Re: <rich:suggestionbox problem
ilya_shaikovsky Mar 22, 2010 8:02 AM (in response to eugenbesel)point a4j:support to onselect.
-
9. Re: <rich:suggestionbox problem
eugenbesel Mar 22, 2010 12:37 PM (in response to ilya_shaikovsky)hello Ilja,
in your code
you iterate throw two columns. You have two inputFields and two SuggestionBoxes.
but each suggestionBox has
it is always the same, or not?<f:param name="sbid" value="sbid"/>
how do you know in bbean whether the user clicked inputtext1 or inputtext2???
should the value ofFacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("sbid")
be always sbid ??? -
10. Re: <rich:suggestionbox problem
eugenbesel Mar 23, 2010 2:41 AM (in response to ilya_shaikovsky)hello Ilja,
you are right the parameter of sbid is the column name.
when I enter some letter into inputField, the method autocomplete is called. On the end of the method is the result also not empty, BUT the suggestionBox is not opend.
Do you have some idea why?
did I implement something wrong?
my code:
<rich:columns value="#{myDataTable.columns}" var="columns"
index="ind" id="filterTable">
<h:panelGrid columns="1">
<h:outputText value="#{columns}"></h:outputText><h:inputText id="TextFilter_#{columns}" value="#{myDataTable.columnFilterValues[columns]}">
<rich:suggestionbox id="suggestionBoxForTextId_#{columns}" for="TextFilter_#{columns}"suggestionAction="#{myDataTable.autocomplete}" var="result">
<f:param name="sbid" value="#{columns}"/>
<h:outputText value="#{result}"/>
</rich:suggestionbox>
</h:inputText>public Set<String> autocomplete(Object suggest) {
String column = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("sbid");
int index = 0;
for(int i = 0;i<getColumns().size();i++){
if(getColumns().get(i).equals(column)){
index = i;
break;
}
}
String pref = (String) suggest;Set<String> result = new HashSet<String>();
Iterator<DataRow> iterator = resultList.iterator();
while (iterator.hasNext()) {
DataRow elem = (iterator.next());
if ((elem.getRowData().get(index) != null
&& elem.getRowData().get(index).toLowerCase().indexOf(pref.toLowerCase()) == 0)
|| "".equals(pref)) {
result.add(elem.getRowData().get(index));}
}
return result;
}
-
11. Re: <rich:suggestionbox problem
eugenbesel Mar 23, 2010 2:48 AM (in response to eugenbesel)I have implemeted only one field with suggestionBox and <f:param
and it works.
can it be possible that suggestionBox has a problem with my dynamic generation??
-
12. Re: <rich:suggestionbox problem
eugenbesel Mar 24, 2010 3:55 AM (in response to ilya_shaikovsky)I have heard that the component suggestionBox have a problem if I set it into one table.
does anybody know this problem?
I tried to implement it with dataGrid and Table and got the same behavior. The action Method is called, but the sugestionBox was not opened.
-
13. Re: <rich:suggestionbox problem
ilya_shaikovsky Mar 29, 2010 5:50 AM (in response to eugenbesel)no in general there should be no problems with suggestion usage in tables., I made some tests in the past and it worked fine for me.
-
14. Re: <rich:suggestionbox problem
jaacen Nov 29, 2010 6:09 PM (in response to eugenbesel)I am having that problem. I have a rich:suggestBox that works perfectly until i put it inside a h:dataTable at which point I notice this in a4j:log:
...
debug[15:45:12,189]: call getElementById for id= edit-form:phNumbers:suggestionBoxIDa:suggestwarn[15:45:12,189]: Node for replace by response with id edit-form:phNumbers:suggestionBoxIDa:suggest not found in document...by doing a view source in the browser it looks to me like it should be calling getElementById for id edit-form:phNumbers:0:suggestionBoxIDa:suggest (where 0 is the dataTable row index)here's my code:<h:dataTable rows="3" value="#{myBean.fruits}" var="testTable" >
<h:column id="colA" >
<h:inputText id="s" value="#{myBean.s}" />
<rich:suggestionbox id="suggestionBoxIDa" var="v" for="s" ajaxSingle="false" selfRendered="true" suggestionAction="#{myBean.picker.autocomplete}">
<h:column>
<h:outputText value="#{v.label}" />
</h:column>
</rich:suggestionbox>
</h:column>
<h:column >
<h:outputText value="#{testTable}"/>
</h:column>
</h:dataTable>note that myBean.picker.autocomplete IS firing (I checked this with a logger) but the suggestionbox is NOT rendering in the page. (once again, works FINE if I remove the dataTable)