-
1. Re: seam validation + rich:suggestionbox
idyoshin Dec 21, 2009 3:09 PM (in response to mafym)Have a look into forums.
In general that value is defined via fetchValue property.
Recently I've answered that questions on using suggestionbox My response
Best regards,
Ilya Dyoshin
-
2. Re: seam validation + rich:suggestionbox
mafym Dec 21, 2009 5:11 PM (in response to mafym)I saw the post you mention, but is is quite complicated, I need a more simplified structure and to use the s:decorate--edit.xhtml combination.
Well I have added fetchValue but there is no change. Also I don't need a converter, because I need only the String value on an object from the list returned by the suggest action not the whole object.
What else do you think it is missing from my code?
Thanks again!
-
3. Re: seam validation + rich:suggestionbox
germanescobar Dec 21, 2009 7:17 PM (in response to mafym)Take a look at this code:
<s:decorate id="decCountry" template="layout/edit.xhtml"> <ui:define name="label">Country</ui:define> <h:inputText id="txtCountry" value="#{countriesBean.selectedCountry.name}"> <rich:suggestionbox id="suggestionBox" for="txtCountry" fetchValue="#{country.name}" suggestionAction="#{countriesBean.autocomplete}" var="country" minChars="2"> <h:column> <h:outputText value="#{country.name}" /> </h:column> <a4j:support event="onselect"> <f:setPropertyActionListener value="#{country}" target="#{countriesBean.selectedCountry}" /> </a4j:support> </rich:suggestionbox> </h:inputText> </s:decorate>
And the bean would be:
@Name("countriesBean") @Scope(ScopeType.CONVERSATION) public class CountriesBean { private Country selectedCountry; public CountriesBean() { selectedCountry = new Country(); } public List<Country> autocomplete(Object suggestion) { // retrieve the countries } // getters and setters }
-
4. Re: seam validation + rich:suggestionbox
idyoshin Dec 21, 2009 7:35 PM (in response to mafym)Hello German,
Sorry, I've looked at your code and don't get it.
You're about creating new object with the same name ? Or you're trying to bind selected object.
If you want to have a user possible to select object with viewing the selected country name try following code:
<s:decorate id="decCountry" template="layout/edit.xhtml"> <ui:define name="label">Country</ui:define> <h:inputText id="txtCountry"/> <rich:suggestionbox id="suggestionBox" for="txtCountry" fetchValue="#{country.name}" suggestionAction="#{countriesBean.autocomplete}" var="country" minChars="2"> <h:column> <h:outputText value="#{country.name}" /> </h:column> <a4j:support event="onselect" reRender="countryInfoOutput"> <f:setPropertyActionListener value="#{country}" target="#{countriesBean.selectedCountry}" /> </a4j:support> </rich:suggestionbox> <br /> Selected country is <h:outputText value="#{countriesBean.selectedCountry.name}" id="countryInfoOutput"/> </s:decorate>
in your initial case you having problem with sonething I'd like to call "double binding":
from one point of view the value of your textInput should be replaced by fetchValue from the other point of view - it is binded to the current selected bean Name property, nevertheless its the same value - for Richfaces its a problem - you're editing the object and when you selected you replaced the object with another one.
the last outputText which outputs countriesBean.selectedCountry.name is used for outputing the selectedCountry name between non-ajax post requests.
Regards! Let me know if this helped.
Ilya Dyoshin
-