accessing transition in a quot;onchangequot; property
Hi,I need to create a form that will submit itself every time a lt;h:selectBooleanCheckboxgt; value changes, right now I'm using the following code:Code:
lt;h:selectBooleanCheckbox title=quot;advancedSearchquot; value=quot;#{userSearchCriteria.advancedSearch}quot; onchange=quot;this.form.submit()quot;gt;
lt;/h:selectBooleanCheckboxgt;
Advanced Search
Actually what I really want is a fragment to be re rendered when I select/deselect the quot;Advanced Searchquot; check box. Is there any way to do this using spring-faces (MyFaces) or even a4j?
In a other issue I'm getting the following exception when I try to render a fragment on a flow transition:
Code:
java.lang.IllegalArgumentException: Component to be rendered with id 'fragmentAuthList' could not be found.
at org..util.Assert.notNull(Assert.java:112)
at org..faces.ui.AjaxViewRoot.findContainingFormId(AjaxViewRoot.java:194)
at org..faces.ui.AjaxViewRoot.updateFormAction(AjaxViewRoot.java:178)
at org..faces.ui.AjaxViewRoot.encodeAll(AjaxViewRoot.java:86)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
at org..faces.webflow.JsfView.render(JsfView.java:83)
Even thought I've added the fragment correctly as show on the DEBUG:Code:
2008-04-10 16:10:33,156 DEBUG [org..webflow.engine.ViewState] - lt; Flash scope = map['webflowRenderFragments' -gt; arraylt;Stringgt;['fragmentAuthList'], 'renderResponse' -gt; true]gt;
If needed to I can submit a JIRA issue.Thanks
Pedro Casagrande de Campos
Originally Posted by pccamposHi,I need to create a form that will submit itself every time a lt;h:selectBooleanCheckboxgt; value changes
I'm currently using RichFaces to achive that:Code:
lt;h:selectBooleanCheckbox value=quot;#{bean.property}quot;gt;
lt;a4j:support event=quot;onchangequot; reRender=quot;someIdquot;/gt;
lt;/h:selectBooleanCheckboxgt;
Regarding your second problem, I assume you have quot;rendered=conditionquot; in your component and the first time the condition is evaluated to false. This results that the id will not placed into the DOM and will not be found for updates.
With RichFaces you can use lt; a4j: outputPanel gt; to solve that problem.
- Peter
Thanks for the quick answer.
I will give RichFaces a try!
Regarding the second problem, I'm actually defining this fragment on a second view state, all my fragments on the starting view state gets processed correctly, on this second view state I cannot render it, although when I reference it on the processingIds property on some tags it gets processed.
I'm using myfaces 1.2.2 and the fragment isn't on a popup form by the way.
I should point out that there is a component in Spring Faces similar to the RichFaces a4j:support component. This component is not currently shown in the sample, but it is documented in the new RC1 reference docs and the spring-faces tld.
With our version, the code would be:Code:
lt;sf:ajaxEvent event=quot;onchangequot;gt; lt;h:selectBooleanCheckbox title=quot;advancedSearchquot; value=quot;#{userSearchCriteria.advancedSearch}quot;/gt;
lt;/sf:ajaxEventgt;I am using this Spring Faces component example in my webflow app and it re-renders a fragment of my page. I am also using Trinidad and skins. After the onchange re-renders the fragment which includes a trinidad table (tr:table), the table no longer has the trinidad skins applied. I have compared the source before and after clicking the checkbox and there is no difference. If I select another trinidad component that also re-renders the table fragment, the table is displayed with the skin. Any idea what is causing this?
As you can see in my code below one difference is the Spring faces component requires the h:form
Code:
lt;ui:fragment id=quot;searchFragmentquot;gt; lt;tr:form id=quot;searchquot;gt; lt;tr:inputText value=quot;#{searchCriteria.searchText}quot;/gt; lt;tr:commandButton text=quot;Searchquot; action=quot;searchOpquot;/gt; lt;/tr:formgt;
lt;/ui:fragmentgt;
lt;ui:fragment id=quot;filterFragmentquot;gt; lt;h:form id=quot;filterFormquot;gt; lt;sf:ajaxEvent event=quot;onchangequot; action=quot;filterResultsquot;gt; lt;tr:selectBooleanCheckbox text=quot;Filter Opquot; value=quot;#{searchCriteria.filterOp}quot;/gt; lt;/sf:ajaxEventgt; lt;/h:formgt;
lt;/ui:fragmentgt;
lt;ui:fragment id=quot;opFragmentquot;gt; lt;tr:form id = quot;opFormquot;gt; lt;tr:table var=quot;opquot; value=quot;#{ops}quot;gt; ....list of columns.... lt;/tr:tablegt; lt;/tr:formgt;
lt;/ui:fragmentgt;This is likely the unfortunate problem that frequently occurs in JSF when trying to mix Ajax components from different libraries. I would suspect that the Trinidad components need some special knowledge to render differently on an Ajax request, but if Spring Faces is initiating that request, they don't have that knowledge. This story will hopefully improve greatly with JSF 2.0.
Thanks Jeremy.
Until that is fixed, I added a hidden button and I use an onchange javascript function to process the button's clicked event. |