Re: How to write this elegantly in JSP/EL

2007-06-24 Thread ben short

And your not happ with just using...

%=com.libris4you.books.maintenancepanel.AuthorTabController.DATA_PHOTO_WIDTH%



On 6/24/07, Hassan Schroeder [EMAIL PROTECTED] wrote:

On 6/23/07, Nikola Milutinovic [EMAIL PROTECTED] wrote:

 The answer is simple, imageUrl is calculated in the controller/servlet for each request. 
com.libris4youDATA_PHOTO_HEIGHT is a constant embedded in the Java code, where it belongs. And, 
here is another one: in your example DATA_PHOTO_HEIGHT is the name of the variable. In my example, I 
have already made THAT name a constant in the Java class.

Uh, what?  Use of the `c:out` format vs. simple EL has nothing to do
with where the value is coming from.

--
Hassan Schroeder  [EMAIL PROTECTED]

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




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



Re: How to write this elegantly in JSP/EL

2007-06-23 Thread Nikola Milutinovic
   img src=${imageUrl} alt=Author photo height=c:out
   value=${DATA_PHOTO_HEIGHT}/ width=c:out
   value=${DATA_PHOTO_WIDTH}/ /
 
  (sigh) I feared as much. It is just that I hate JSTL tags inside another 
  tag's attributes.
 
 Why would you use `src=${imageUrl}` and then use the clumsy
 'c:out' form? What's wrong with `height=${DATA_PHOTO_HEIGHT}`?

The answer is simple, imageUrl is calculated in the controller/servlet for 
each request. com.libris4youDATA_PHOTO_HEIGHT is a constant embedded in 
the Java code, where it belongs. And, here is another one: in your example 
DATA_PHOTO_HEIGHT is the name of the variable. In my example, I have already 
made THAT name a constant in the Java class.

What I was looking for is having to change that name only in one place - Java 
code. It could be that my quest is futile, but I wanted to pursue it and see 
where it leads me.

Nix.





   

Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/

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



Re: How to write this elegantly in JSP/EL

2007-06-23 Thread Nikola Milutinovic
 Also you talk about the DATA_PHOTO_HEIGHT and DATA_PHOTO_WIDTH
 properties being static propertys of the AuthorController class. Why
 not create a Constant object called PHOTO or something. make the
 height and width proper static on that, then pass that into the model.
 Then you can use the following in your jsp page
 
 img src=${imageUrl} alt=Author photo height=${PHOTO.HEIGHT}
 width=${PHOTO.WIDTH}/

Alas this is not what I'm looking for.

My desire was to avoid code duplication and I spotted it in the fact that I had 
photoHeight (as a String) in two places:

1. in controller, which bound the value under that name
2. in JSPF which used that name in EL

I wanted to be able to specify the actual name in just one place.

Nix.





  
___
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html

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



Re: How to write this elegantly in JSP/EL

2007-06-23 Thread Hassan Schroeder

On 6/23/07, Nikola Milutinovic [EMAIL PROTECTED] wrote:


The answer is simple, imageUrl is calculated in the controller/servlet for each request. 
com.libris4youDATA_PHOTO_HEIGHT is a constant embedded in the Java code, where it belongs. 
And, here is another one: in your example DATA_PHOTO_HEIGHT is the name of the variable. In my 
example, I have already made THAT name a constant in the Java class.


Uh, what?  Use of the `c:out` format vs. simple EL has nothing to do
with where the value is coming from.

--
Hassan Schroeder  [EMAIL PROTECTED]

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



How to write this elegantly in JSP/EL

2007-06-22 Thread Nikola Milutinovic
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]



Re: How to write this elegantly in JSP/EL

2007-06-22 Thread Rashmi Rubdi

On 6/22/07, Nikola Milutinovic [EMAIL PROTECTED] wrote:

Hi all.

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


I ask JSP, EL and JSTL questions here

http://jakarta.apache.org/taglibs/

or

http://forum.java.sun.com/forum.jspa?forumID=45

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



Re: How to write this elegantly in JSP/EL

2007-06-22 Thread ben short

I think the following should do you

img src=${imageUrl} alt=Author photo height=c:out
value=${DATA_PHOTO_HEIGHT}/ width=c:out
value=${DATA_PHOTO_WIDTH}/ /

On 6/22/07, Johnny Kewl [EMAIL PROTECTED] wrote:


Hi Nikola, never done it, but I think you have to override the resolver.

ie instead of the standard resolver, which looks for standard properties or
custom classes declared thru XML yours will tie to a class in your app.
Managed to find an ok article maybe its enuf for you to find the
relevent code in spring, and steal it ;)

http://today.java.net/pub/a/today/2006/03/07/unified-jsp-jsf-expression-language.html

- Original Message -
From: Nikola Milutinovic [EMAIL PROTECTED]
To: Tomcat Users List users@tomcat.apache.org
Sent: Friday, June 22, 2007 10:46 AM
Subject: How to write this elegantly in JSP/EL


 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]




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




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



Re: How to write this elegantly in JSP/EL

2007-06-22 Thread Johnny Kewl


Hi Nikola, never done it, but I think you have to override the resolver.

ie instead of the standard resolver, which looks for standard properties or 
custom classes declared thru XML yours will tie to a class in your app.
Managed to find an ok article maybe its enuf for you to find the 
relevent code in spring, and steal it ;)


http://today.java.net/pub/a/today/2006/03/07/unified-jsp-jsf-expression-language.html

- Original Message - 
From: Nikola Milutinovic [EMAIL PROTECTED]

To: Tomcat Users List users@tomcat.apache.org
Sent: Friday, June 22, 2007 10:46 AM
Subject: How to write this elegantly in JSP/EL



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]





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



Re: How to write this elegantly in JSP/EL

2007-06-22 Thread Nikola Milutinovic
Thank you all who responded.

 I think the following should do you

 img src=${imageUrl} alt=Author photo height=c:out
 value=${DATA_PHOTO_HEIGHT}/ width=c:out
 value=${DATA_PHOTO_WIDTH}/ /

(sigh) I feared as much. It is just that I hate JSTL tags inside another tag's 
attributes.

 On 6/22/07, Johnny Kewl [EMAIL PROTECTED] wrote:
 
  Hi Nikola, never done it, but I think you have to override the resolver.
 
  ie instead of the standard resolver, which looks for standard properties or
  custom classes declared thru XML yours will tie to a class in your app.
  Managed to find an ok article maybe its enuf for you to find the
  relevent code in spring, and steal it ;)
 
  http://today.java.net/pub/a/today/2006/03/07/unified-jsp-jsf-expression-language.html

I will definitely look it up.

Is there perhaps some useful function taglib?

Something like:

${fn.getProperty( 
com.libris4you.books.controller.AuthorController.DATA_PHOTO_HEIGHT )}

Nix.





 

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

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



Re: How to write this elegantly in JSP/EL

2007-06-22 Thread Hassan Schroeder

On 6/22/07, Nikola Milutinovic [EMAIL PROTECTED] wrote:


 img src=${imageUrl} alt=Author photo height=c:out
 value=${DATA_PHOTO_HEIGHT}/ width=c:out
 value=${DATA_PHOTO_WIDTH}/ /

(sigh) I feared as much. It is just that I hate JSTL tags inside another tag's 
attributes.


Why would you use `src=${imageUrl}` and then use the clumsy
'c:out' form? What's wrong with `height=${DATA_PHOTO_HEIGHT}`?


Is there perhaps some useful function taglib?


That said, writing your own tag libs is pretty easy, and worth while if
it's something repetitious.

YMMV,
--
Hassan Schroeder  [EMAIL PROTECTED]

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



Re: How to write this elegantly in JSP/EL

2007-06-22 Thread ben short

Well you learn something new everyday, I wasn't aware that ${X} worked
like c:out value=${X}/

Also you talk about the DATA_PHOTO_HEIGHT and DATA_PHOTO_WIDTH
properties being static propertys of the AuthorController class. Why
not create a Constant object called PHOTO or something. make the
height and width proper static on that, then pass that into the model.
Then you can use the following in your jsp page

img src=${imageUrl} alt=Author photo height=${PHOTO.HEIGHT}
width=${PHOTO.WIDTH}/

Which doesn't seem that bad to me.

With your spring setup you could also create an HandlerInterceptor [1]
and add it to your url mapping, that adds the PHOTO object to the
model after the controller has process the request, so as not to
clutter up your controllers.

[1] 
http://www.springframework.org/docs/api/org/springframework/web/servlet/HandlerInterceptor.html





On 6/22/07, Hassan Schroeder [EMAIL PROTECTED] wrote:

On 6/22/07, Nikola Milutinovic [EMAIL PROTECTED] wrote:

  img src=${imageUrl} alt=Author photo height=c:out
  value=${DATA_PHOTO_HEIGHT}/ width=c:out
  value=${DATA_PHOTO_WIDTH}/ /

 (sigh) I feared as much. It is just that I hate JSTL tags inside another 
tag's attributes.

Why would you use `src=${imageUrl}` and then use the clumsy
'c:out' form? What's wrong with `height=${DATA_PHOTO_HEIGHT}`?

 Is there perhaps some useful function taglib?

That said, writing your own tag libs is pretty easy, and worth while if
it's something repetitious.

YMMV,
--
Hassan Schroeder  [EMAIL PROTECTED]

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




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