I think you are re-inventing something here.

To do what you are wanting is already in struts to some degree.

you have your User Bean, You define an formbean which either contains UserBean or contains fields that match UserBean

on your jsp page you create something like

<html:html local="true">
<html:form action="" method="post">
<bean:message key="resource.key"/><html:text propery="userId"/>
</html:form>
</html:html>

This will print the UserID's label from the Resource file and give you internationalization.

This might be easier than embedding HTML into a tag or bean.

Inactive hide details for Daniel Łaś <[EMAIL PROTECTED]>Daniel Łaś <[EMAIL PROTECTED]>


          Daniel Łaś <[EMAIL PROTECTED]>

          07/22/2005 09:03 AM

          Please respond to
          "Struts Users Mailing List" <user@struts.apache.org>

To

Struts Users Mailing List <user@struts.apache.org>

cc


Subject

Design question

Hi

I'm interested in yours opinions about following design approach. I'd
like to create some kind of "view" beans for viewable model beans. Those
view beans can generate HTML for attached model bean. This generated
HTML is based on resources, so I am able to generate different HTML code
depending on session locale.

Lets say I create one model bean User
I created UserView with reference pointing to User.
I attached reference to MessageResources in UserView bean during action
execution with getResources(request)
In my JSP I added: <bean:write name="UserView" property="content"
filter="false"/> which calls getContent() method
UserView method body is:
public String getContent()
{
   return messages.getMessage("user.login")+user.getLogin();
}
where:
messages - private UserView member of class MessageResources
user - private UserView member of class User
user.login - resources key

Everything worked well, but when I changed session locale my UserView
bean generates output for previus locale. I think that I have to update
messages member of UserView bean or use reference to other object, maybe
servlet which will be constant during session.

I'm new to struts, so I'd like to know if there are some other issues
connected to mentioned design and struts?

Regards

--
Daniel Łaś <[EMAIL PROTECTED]>

e-direct Polska sp. z o.o.
ul. 1-go Maja 9
45-068 Opole
tel. +48 77 44 17 868


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to