Hi all.

This is not really TC related, but more JSP and EL question, but I thought I'd 
ask.

I would like to have an elegant way of using constants from Java classes in EL. 
This is a relatively good illustration of what I am talking about. Take, for 
instance, a Spring controller. It has a method where the programmer can bind 
objects to model-and-view, which basically binds it to a request or session 
scope. It is very similar to a plain Servlet doing "request.setAttribute( 
"name", value )".

public class SomeController extends SimpleFormController {

    public static final String DATA_PHOTO_WIDTH = "photoWidth";
    public static final String DATA_PHOTO_HEIGHT = "photoHeight";

    ...

    protected referenceData( ... ) {

        ...

        modelAndView.put( DATA_PHOTO_WIDTH, photoWidth );
       modelAndView.put( DATA_PHOTO_HEIGHT, photoHeight );

        ...

    }

...

}


And then in JSPF or JSP:



<img src="${imageUrl}" alt="Author photo" height="${photoHeight}" 
width="${photoWidth}" />


Notice that the EL variable name is the same as that constant. So, I have 2 
places to keep in synch. If I wrote that in a scriptlet, it would be correct, 
from the point of "do not duplicate code":



<%= request.getAttribute( 
com.libris4you.books.maintenancepanel.AuthorTabController.DATA_PHOTO_WIDTH ) %>

Now, how could I do the same in EL?


Something like (tongue in cheek):

width="${=com.libris4you.books.maintenancepanel.AuthorTabController.DATA_PHOTO_WIDTH}"

Did I miss something crucial in EL?

Nix.




       
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to