This content has been marked as final.
Show 4 replies
-
1. Re: Dynamic value expression in richfaces
apg9595 Aug 21, 2009 4:23 PM (in response to apg9595)if the above is not possible how do i create this value expression dynamically through JAVA API, any suggestions?
#{baseController.name} -
2. Re: Dynamic value expression in richfaces
johndoe123 Aug 24, 2009 9:19 AM (in response to apg9595)Hi!
Why not use my DynamicEl Component for Seam Expressions? I think you can port it quite easily to other ELs. It's not optimal yet, but it's a start. It'd need to be enhanced to support more than one Expression on a page.public class DynamicExpressionLanguage { private String dynamicEL; public Expressions.ValueExpression<Object> getValueExpression() { Expressions expressions = Expressions.instance(); String eval = "#{" + dynamicEL + "}"; if (dynamicEL == null) { eval = "#{'itsnull'}"; } Expressions.ValueExpression<Object> el = expressions.createValueExpression(eval); return el; } public void setCurrentValue(Object value) { Expressions.ValueExpression<Object> el = getValueExpression(); el.setValue(value); } public Object getCurrentValue() { return getValueExpression().getValue(); } public void invoke(Object... objects) { Expressions expressions = Expressions.instance(); String eval = "#{" + dynamicEL + "}"; if (dynamicEL == null) { eval = "#{'itsnull'}"; } try { Expressions.MethodExpression<Object> el = expressions.createMethodExpression(eval); el.invoke(objects); } catch (Exception ex) { FacesContext.getCurrentInstance().addMessage("messages", new FacesMessage("Could not call desired action: " + eval)); } } public void setDynamicEL(String dynString) { this.dynamicEL = dynString; } public String getDynamicEL() { return this.dynamicEL; } }
Usage:<h:form> <h:inputText value="#{comp.dynel}" /> <h:outputText value="#{comp.dynel.currentValue}" /> <h:commandButton value="show" /> </h:form>
Now input an el expression (without #{ and } ) like
"aComponent.aProperty" and watch the output. -
3. Re: Dynamic value expression in richfaces
johndoe123 Aug 24, 2009 9:28 AM (in response to apg9595)fixt
<h:form> <h:inputText value="#{comp.dynel.dynamicEL}" /> <h:outputText value="#{comp.dynel.currentValue}" /> <h:commandButton value="show" /> </h:form>
-
4. Re: Dynamic value expression in richfaces
apg9595 Aug 24, 2009 1:18 PM (in response to apg9595)Sounds cool, thanks a ton. Will check it out.