Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested:write

 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a nested:write tag to write the value of a property.What I need to do is just show part of this value...

name: John Smith

<nested write property="name"/>

For instance, instead of showing: "John Smith",just show "John..."

is there a way to do this with this tag? I think there is no such a thing as a size attribute...

thanks...
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The place to manipulate bean properties is in the bean itself, not in the JSP. So, for example, if you need only the first name, create a getter on the JavaBean named getFirstName() that does whatever manipulation of the name property you need to do. Then in your JSP, simply put:
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok but in those cases the presentation layer is not in charge of that,meaning the JSP? you're not supposed to do changes for presentation in another layer...
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JavaBean used by the presentation layer is often referred to as a Transfer Object (TO) or sometimes a Data Transfer Object(DTO). The purpose of this type of object is to act as means of transferring data between the view and the model. Even though technically it's part of the model, it has to be used by both the model and the view. It is inescapable that it must present the data in a format that is acceptable to the view. Putting logic in this type of object to present data in a certain way is a commonly accepted practice, and is far preferable to muddying up your JSP with scriptlets to perform the same function.
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok,thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic