-
1. Re: Ajax onchange Event problem
maxseam Dec 11, 2008 5:51 PM (in response to maxseam)Now I tried a simple alert message on an changeEvent of a rich:inplaceSelect:
<s:decorate id="tcountyField" template="layout/edit.xhtml"> <ui:define name="label"> County </ui:define> <rich:inplaceSelect id='countyInput' defaultLabel="#{tuserHome.instance.tdistrict.tregion.tcounty}"> <f:selectItems value="#{tcountyList.resultListAsSelectItem}" /> <a:support id="countyAjax" action="alert ('changed')" event="onchange"/> </rich:inplaceSelect> </s:decorate>
It does not work too. But I think it's a very basic and simple example. Is there a mistake I can't examine? I searched a long time for this issue, but wasn't able to find an answer.
Maybe inplaceSelect doesn't support onchange? I don't thinkt that's the case, but I don't know what I can try next.
Maybe someone has more experience and can tell me what's the problem here?
Thanks!
regards,
max. -
2. Re: Ajax onchange Event problem
maxseam Dec 12, 2008 1:40 AM (in response to maxseam)I solved it. I think it's a bug in inplaceSelect, that it doesn't support the event onchange. I got it working with selectOneMenu.
regards,
Christian. -
3. Re: Ajax onchange Event problem
walternvlpe Feb 11, 2009 11:11 PM (in response to maxseam)I have now some problem like yours
I have 2 :selectOnes with Ajax Support, One for countries, another one for states, and the third control is one inputText REQUIRED for the district name
When Page reRender the Country selectOne , one warn Error Appear cause district name is REQUIRED, and Ajax didnt do the work, ot means I cant see the states in the second selectOneDo u know how to solve this??, Does any One can help me??
Hope you can!!!
My best regardsGGB
-
4. Re: Ajax onchange Event problem
francof Feb 12, 2009 3:51 PM (in response to maxseam)I do not have an example - this is on my todo list
But you can take a look at an example here
http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf?c=support&tab=selectsThe richfaces demo war is really valuable, I recommend you install to your Eclipse workspace and look at the backing bean code.
I also recommend putting a4j log component on your page for testing.
<a4j:log level="ERROR" popup="false" width="400" height="200"/>
Good luck guys
Franco
-
5. Re: Ajax onchange Event problem
walternvlpe Feb 13, 2009 3:27 PM (in response to maxseam)
_My Ajax onchange Event problem is
When I trigger onchange Event in the first combo(the countries one), It call Ajax support to fill the second combo(the states one), it works perfect only if I dont have more fields in the form,
When I have some fields that are REQUIRED for Hibernate to save, even if I dont want to save the form yet, Hibernate send me an error message(After I trigger onchange Event in the first combo), cause this fields are REQUIRED.
How can I solve this , because I need Country & State changes any time, without fill the other fields.
Regards
GGB -
6. Re: Ajax onchange Event problem
hattifnat Feb 26, 2009 5:14 PM (in response to maxseam)It would be great if someone provided a hint on that - I have the same problem.. I'm editing an entity, some of the (text) fields are mandatory. Plus there are two 'dependant selects' (selectOneMenus) - the ones we are talking about here. I'd like the selectOneMenus be updated but without the bean being submitted/validated. Right now the validation stops the selects to be updated when some of the fields are invalid. When the text fields are valid, the solution works fine.
-
7. Re: Ajax onchange Event problem
hattifnat Feb 27, 2009 9:57 AM (in response to maxseam)Ok, I figured it out - this thread helped me: http://www.seamframework.org/Community/SeamA4JSelectonemenusAndValidationRichMessage. Generally, I surrounded the first (
parent
) selectOneMenu with a4j:region tag. This causes that during Ajax submission only the region is submitted and not the whole form, so no validation is done. When the whole form is submitted, then the bean gets validated. -
8. Re: Ajax onchange Event problem
jeff.haynes1 Dec 2, 2009 6:33 PM (in response to maxseam)You can use a4j:support with rich:inplaceSelect by setting event="onviewactivated" and ajaxSingle="true" in the a4j:support tag. I prefer using ajaxSingle="true" over the a4j:region tag because it looks cleaner in code, it keeps the required behaviour encapsulated in the component(s) that it's applied to, and it's (at least) one less component that needs to exist in the JSF tree.
Here's the modified code example from the first post:
<s:decorate id="tcountyField" template="layout/edit.xhtml"> <ui:define name="label"> County </ui:define> <rich:inplaceSelect id='countyInput' defaultLabel="#{tuserHome.instance.tdistrict.tregion.tcounty}"> <f:selectItems value="#{tcountyList.resultListAsSelectItem}" /> <a:support event="onviewactivated" ajaxSingle="true" /> </rich:inplaceSelect> </s:decorate> <s:decorate id="tregionField" template="layout/edit.xhtml"> <ui:define name="label"> District </ui:define> <rich:inplaceSelect id="regionSelect" value="#{tuserHome.instance.tdistrict}" > <f:selectItems id="Field" value="#{tdistrictList.getDistrictsForCountyAsSelectItem(rich:findComponent('tcountyInput').value)}"/> </rich:inplaceSelect> </s:decorate>