-
1. Re: <s:validateAll> and
pmuir Jan 19, 2007 7:41 AM (in response to vladimir.kovalyuk)Can you post the facelet you are trying to get working?
-
2. Re: <s:validateAll> and
vladimir.kovalyuk Jan 19, 2007 7:47 AM (in response to vladimir.kovalyuk)I fixed some lines in that class got NPE.
I realized that validate() takes script component tag parameters instead of evaluated expression. I debugged a lot JSF RI 1.2 and EL and realized that EL defers evaluation. Thus by calling valueBinding.getExpressionString() in ModelValidator.validate() Seam obtains just expression as it looks like but not as it should be evaluated.
I don't see a workaround. I commented <s:validateAll> and now all works fine except hibernate validators. But I love this feature in Seam and will count on it in the future.
Some excerpts from my code:
source tag:<ui:composition> <c:if test="#{empty id}"> <c:set var="id" value="#{name}"/> </c:if> <c:if test="#{empty readonly}"> <c:set var="readonly" value="#{details.readonly}"/> </c:if> <!-- detect type of editor --> <c:if test="#{empty editor}"> <c:set var="editor" value="#{my:detectEditor(object, name)}"/> </c:if> <!-- insert controls --> <c:if test="#{editor == 'text'}"> <h:inputText id="#{id}" value="${object[name]}" readonly="#{readonly}"> <ui:insert/> </h:inputText> </c:if> <c:if test="#{editor == 'textarea'}"> <h:inputTextarea id="#{id}" value="#{object[name]}" readonly="#{readonly}"> <ui:insert/> </h:inputTextarea> </c:if> <c:if test="#{editor == 'selectBooleanCheckbox'}"> <h:selectBooleanCheckbox id="#{id}" value="#{object.name}" readonly="#{readonly}"> <ui:insert/> </h:selectBooleanCheckbox> </c:if> </ui:composition>
how tag is used:<s:decorate> <my:property object="#{details.object}" name="name"/> </s:decorate>
As the result expression string is "object[name]". But facelets calculates it as #{details.object.name}
NPE is due to the fact that there is no "object" in searchable contexts.
Please give me an advice how to work around this problem. -
3. Re: <s:validateAll> and
pmuir Jan 19, 2007 7:54 AM (in response to vladimir.kovalyuk)As I suspected ;) There is AFAIK no way around the problem.
As you say, what needs to happen is that you need to be able to ask EL to give you the final expression for expression, but there is no functionality in EL for this.
I know Jacob is aware of this problem and I think he is working on a new version of EL so hopefully that will fix this.
The only way I know to get around this is to extend model validator and make it take a string that references the bean.property to validate against. -
4. Re: <s:validateAll> and
vladimir.kovalyuk Jan 19, 2007 8:50 AM (in response to vladimir.kovalyuk)Bad news :(
I don't want to rewrite UiValidateAll, but it seems that it is the only way.
I haven't realized yet how to build the expression. Probably I will need to access to private field "orig" in some class. It keeps the original expression. It won't be difficult to traverse all the ASF classes and build the final expression.
At least I hope that it is possible. -
5. Re: <s:validateAll> and
pmuir Jan 19, 2007 9:54 AM (in response to vladimir.kovalyuk)It would be great if you can post back any success you have :)