You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Sobkowski, Andrej" <An...@emergis.com> on 2001/11/05 21:49:53 UTC

HTML "beans" vs HTML JSP

Hello,

a quick design question regarding Struts HTML Taglib: the tags generate HTML
from scratch. Wouldn't it be better to add an extra layer of "HTML beans"
that will simply take care of generating the HTML code for the various
elements (input, img, a, ...) and use them in the JSP HTML tags?

I'm asking because in our application we have a set of pretty standard
fields for telephone numbers:
- region code
- number
- extension
- type (home, office, mobile).
These fields are used in exactly the same way in different pages: a user can
add and remove phone numbers (say, up to 3 different phones). This looks to
me as a pretty good case for a custom tag that will take care of all this.

BUT I need to generate my HTML again from scratch. Wouldn't it be better to
use utility HTML classes in order to write something like (pseudo-code):

StringBuffer htmlOutput = new StringBuffer();

HTMLInput input = new HTMLInput("code"); // name to be used or property of
Phone Java Bean
input.setMaxSize(3);
...
HTMLOptions options = new HTMLOptions("type");
options.add("H", "Home"); // code - value
options.add("O", "Office");
options.add("M", "Mobile");
...
htmlOutput..append(input.toHTML()).append(options.toHTML());

The Struts HTML Tags could then use these intermediate "HTML generators" and
add the mapping from the Bean's properties, the I18N and so on.

Just an idea...

Andrej


Re: HTML "beans" vs HTML JSP

Posted by Arron Bates <ar...@keyboardmonkey.com>.
Andrej ,

I just posted a nesting tags solution.
You could nest these phone number objects, even have their own JSP file 
to consistently display them every time, and place the include tag 
inside one of the nesting tags.

Take a look at the example to get a clearer picture. Any of the levels 
in the example can be extracted into it's own include file.
I've used this approach myself... quite nice.


Arron.


Sobkowski, Andrej wrote:

>Hello,
>
>a quick design question regarding Struts HTML Taglib: the tags generate HTML
>from scratch. Wouldn't it be better to add an extra layer of "HTML beans"
>that will....
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: HTML "beans" vs HTML JSP

Posted by Marcelo Vanzin <va...@rededc.com.br>.
Sobkowski, Andrej wrote:

> HTMLInput input = new HTMLInput("code"); // name to be used or property

	I don't know if it is still being developed/maintained, but you may want 
to take a look at:

	http://jakarta.apache.org/ecs/

	Probably there are other efforts like that, but I can't remember any.

-- 
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"We're an underground revolution working overtime"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: HTML "beans" vs HTML JSP

Posted by Sandeep Takhar <sa...@yahoo.com>.
could you include a jsp with this information?

Sandeep
--- "Sobkowski, Andrej" <An...@emergis.com>
wrote:
> Hello,
> 
> a quick design question regarding Struts HTML
> Taglib: the tags generate HTML
> from scratch. Wouldn't it be better to add an extra
> layer of "HTML beans"
> that will simply take care of generating the HTML
> code for the various
> elements (input, img, a, ...) and use them in the
> JSP HTML tags?
> 
> I'm asking because in our application we have a set
> of pretty standard
> fields for telephone numbers:
> - region code
> - number
> - extension
> - type (home, office, mobile).
> These fields are used in exactly the same way in
> different pages: a user can
> add and remove phone numbers (say, up to 3 different
> phones). This looks to
> me as a pretty good case for a custom tag that will
> take care of all this.
> 
> BUT I need to generate my HTML again from scratch.
> Wouldn't it be better to
> use utility HTML classes in order to write something
> like (pseudo-code):
> 
> StringBuffer htmlOutput = new StringBuffer();
> 
> HTMLInput input = new HTMLInput("code"); // name to
> be used or property of
> Phone Java Bean
> input.setMaxSize(3);
> ...
> HTMLOptions options = new HTMLOptions("type");
> options.add("H", "Home"); // code - value
> options.add("O", "Office");
> options.add("M", "Mobile");
> ...
>
htmlOutput..append(input.toHTML()).append(options.toHTML());
> 
> The Struts HTML Tags could then use these
> intermediate "HTML generators" and
> add the mapping from the Bean's properties, the I18N
> and so on.
> 
> Just an idea...
> 
> Andrej
> 
> 


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>