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

Wise Guy (JIRA) jira-events at lists.jboss.org
Mon Jul 23 11:14:48 EDT 2007


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: EL, JSF
    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