[jbossseam-issues] [JBoss JIRA] Reopened: (JBSEAM-1711) Allow variables to be passed into actions as parameters

Wise Guy (JIRA) jira-events at lists.jboss.org
Wed Jul 25 13:03:47 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBSEAM-1711?page=all ]

Wise Guy reopened JBSEAM-1711:
------------------------------

             
I think I was caught unprepared this time but I was wrong.

Even if 'locale' is the name of a system component the page variable should be calculated before searching for a component with that name.

My test proved me right about that doubt that I had. I renamed the variable to 'sel' and ran the application.

The code that was executed was localeSelector(sel.value) :
http://localhost:8080/AuthWebApp/noauth/login.seam?cid=1&actionMethod=noauth%2Flogin.xhtml%3AlocaleSelector.selectLanguage%28sel.value%29

The method localeSelector.selectLanguage(String language) was executed with language=""

I guess Pages.callAction() couldn't figure out what was to be executed. After:
MethodExpression actionExpression = Expressions.instance().createMethodExpression(expression);

The actionExpression did not contain the expression that I expected. Invoking  localeSelector.selectLanguage("") here:
outcome = toString( actionExpression.invoke() );

Returned a null outcome.

Anyways... what must be processed at this stage is a literal string. Something like localeSelector.selectLanguage('de'). After the sel.value is some how evaluated as page variable in the previous request.

PS Now I'm sure I am not able to explain myself :-)


> Allow variables to be passed into actions as parameters
> -------------------------------------------------------
>
>                 Key: JBSEAM-1711
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1711
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: JSF, EL
>    Affects Versions: 2.0.0.BETA1
>         Environment: Seam 2.0.0.BETA1, Facelets
>            Reporter: Wise Guy
>            Priority: Minor
>
> There is a  point missing in the enhancements made to the expression language. Because of this, to me, they look more like a patch than a fully functional feature.
> Seam allows to pass parameters to an action using EL:
> <s:commandButton action="#{hotelBooking.bookHotel(hotel, user)}" class="button" value="Book Hotel" />
> Literal strings are also allowed:
> <h:commandLink action="#{printer.println('Hello world!')}" value="Hello"/>
> This is all specified in:
> Chapter 29. Expression language enhancements
> 29.1. Parameterized Method Bindings
> http://docs.jboss.com/seam/2.0.0.B1/reference/en/html/elenhancements.html
> This syntax, unfortunately, causes problems if you want to pass a variable created by Facelets' repeat tag. This makes it harder to create links dynamically. Let me give you the following example (same as the one in the JBoss Forum Reference):
> <ui:repeat var="locale" value="#{localeSelector.supportedLocales}">
>                 <s:link value="#{locale.label}"
>                         action="#{localeSelector.selectLanguage('#{locale.value}')}"/>
> </ui:repeat>
> You cannot have an expression inside an expression so the code for the action is not valid. A workaround can be declared like this:
> <ui:repeat var="locale" value="#{localeSelector.supportedLocales}">
> <s:link value="locale.value"
>   action="#{localeProvider.updateLocale()}">
>     <f:param name="l" value="#{locale.value}"/>
> </s:link>
> </ui:repeat>
> public void updateLocale() {
>         if (l != null && l.length() > 0) {
>             localeSelector.selectLanguage(l);
>         }
> }
> I think that a simple syntax can be elaborated in which something similar to the original idea can be used.
> Maybe if we use the dollar ($) sign:
> action="#{localeSelector.selectLanguage('${locale.value}')}"
> this would make sense, maybe not (Unified EL has another task assigned to that sign). But if the code is left like this, the url that is generated looks like this:
> http://localhost:8080/WebApp/login.seam?cid=1&actionMethod=login.xhtml%3AlocaleSelector.selectLanguage%28%27%24%7Blocale.value%7D%27%29 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list