You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pankaj Gupta <pa...@hsc.com> on 2006/07/17 11:18:52 UTC

How to create custom tag

Hi All,

I want to create a custom tag which wraps the plain html font tag in 
such a way that it fetches the color of the font to be displayed on a 
pre-configured severity level. Can anyone pl suggest how can I do that.

regards,
Pankaj

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to create custom tag

Posted by David Delbecq <de...@oma.be>.
Use expression language available in jsp 2.0:
<div 
class="${theBean.messageLevel="Error"?"ErrorClass":theBean.messageLevel="Warning"?"WarningClass":"InfoClass"}">
.....
</div>

Pankaj Gupta wrote:
> I dont think CSS can work in this case as the CSS would be static. I 
> want to display color of the font based on the value of severity of 
> message i.e. if the message is critical it should be displayed in red, 
> info in blue, etc. i.e. It would depend on the value of a form bean 
> property.
>
> Li wrote:
>> why not use CSS?
>>
>> On 7/17/06, Pankaj Gupta <pa...@hsc.com> wrote:
>>>
>>> Hi All,
>>>
>>> I want to create a custom tag which wraps the plain html font tag in
>>> such a way that it fetches the color of the font to be displayed on a
>>> pre-configured severity level. Can anyone pl suggest how can I do that.
>>>
>>> regards,
>>> Pankaj
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to create custom tag

Posted by Li <am...@gmail.com>.
Sorry, the last part should be:
<td class="error">
    <html:error/> <!-- you can also use logic:present with html:message
id="error" to represent you text -->
  </td>

On 7/17/06, Li <am...@gmail.com> wrote:
>
> Hi,
>
> CSS sure can do, and how you let your system know whether is error or
> info, or whatever is up to how you code inside your system.
>
> Let'me give you a simple example
>
> in sample.css
>
> .error {
>   color:red;
>   font: 10px;
> }
>
> .success {
>   color:blue;
>   font:10px;
> }
>
> --------------------------
>
> Your have form.jsp / submit-done.jsp, submit-fail.jsp
> - form.jsp : contains a form that would be submitted by user to your
> remote DBMS
> - submit-done.jsp : once form submission is successful, this page is
> rendered, with success info
>   ...
>   <td class="success">
>     You form is submitted successfully!
>   </td>
>  ....
>
> - submit-done.jsp : once form submission is failed, this will be displayed
>   ....
>    <td class="success">
>     <html:error> <!-- you can also use logic:present with html:message
> id="error" to represent you text -->
>   </td>
>
> That's it.
>
>
> On 7/17/06, vijay venkataraman <vi...@ltp.soft.net> wrote:
> >
> > Font Tag is deprecated see
> > http://www.w3.org/TR/html401/present/graphics.html#edef-FONT
> > If you are on JSP 2.0  it is very easy to write a Tag yourself. Just
> > override doTag() method of SimpleTagSupport class.
> >
> > See:
> > http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/SimpleTagSupport.html
> >
> > http://www.sitepoint.com/print/jsp-2-simple-tags - very simple tutorial.
> >
> > I think tomcat 5.x comes bundled with basic examples you should be able
> > to find examples in webapp jsp-examples.
> > Look in folder TOMCAT_HOME\webapps\jsp-examples\jsp2\simpletag for
> > HelloWorldSimpleTag.java.html
> >
> > Thanks,
> > Vijay Venkataraman
> >
> >
> > Bart Busschots wrote:
> >
> > > Anything you can do with a font tag you can do with CSS. In this day
> > > and age no one should be using font tags anymore!
> > >
> > > Bart.
> > >
> > > Pankaj Gupta wrote:
> > >
> > >> I dont think CSS can work in this case as the CSS would be static. I
> > >> want to display color of the font based on the value of severity of
> > >> message i.e. if the message is critical it should be displayed in
> > >> red, info in blue, etc. i.e. It would depend on the value of a form
> > >> bean property.
> > >>
> > >> Li wrote:
> > >>
> > >>> why not use CSS?
> > >>>
> > >>> On 7/17/06, Pankaj Gupta <pankaj.gupta@hsc.com > wrote:
> > >>>
> > >>>>
> > >>>> Hi All,
> > >>>>
> > >>>> I want to create a custom tag which wraps the plain html font tag
> > in
> > >>>> such a way that it fetches the color of the font to be displayed on
> > a
> > >>>> pre-configured severity level. Can anyone pl suggest how can I do
> > >>>> that.
> > >>>>
> > >>>> regards,
> > >>>> Pankaj
> > >>>>
> > >>>>
> > ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>>> For additional commands, e-mail: user-help@struts.apache.org
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> >
> >
> > ------------------------------DISCLAIMER------------------------------
> > This message is for the named person's use only. It may contain
> > confidential, proprietary or legally privileged information. No
> > confidentiality or privilege is waived or lost by any mistransmission.
> >
> > If you receive this message in error, please immediately delete it and
> > all copies of it from your system, destroy any hard copies of it and
> > notify the sender. You must not, directly or indirectly, use, disclose,
> > distribute, print, or copy any part of this message if you are not the
> > intended recipient.
> >
> > Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each
> > reserve the right to monitor all e-mail communications through its
> > networks.
> >
> > Any views expressed in this message are those of the
> > individual sender, except where the message states otherwise and the
> > sender is authorized to state them to be the views of any such entity.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> When we invent time, we invent death.
>



-- 
When we invent time, we invent death.

Re: How to create custom tag

Posted by Li <am...@gmail.com>.
Hi,

CSS sure can do, and how you let your system know whether is error or info,
or whatever is up to how you code inside your system.

Let'me give you a simple example

in sample.css

.error {
  color:red;
  font: 10px;
}

.success {
  color:blue;
  font:10px;
}

--------------------------

Your have form.jsp / submit-done.jsp, submit-fail.jsp
- form.jsp : contains a form that would be submitted by user to your remote
DBMS
- submit-done.jsp : once form submission is successful, this page is
rendered, with success info
  ...
  <td class="success">
    You form is submitted successfully!
  </td>
 ....

- submit-done.jsp : once form submission is failed, this will be displayed
  ....
   <td class="success">
    <html:error> <!-- you can also use logic:present with html:message
id="error" to represent you text -->
  </td>

That's it.

On 7/17/06, vijay venkataraman <vi...@ltp.soft.net> wrote:
>
> Font Tag is deprecated see
> http://www.w3.org/TR/html401/present/graphics.html#edef-FONT
> If you are on JSP 2.0  it is very easy to write a Tag yourself. Just
> override doTag() method of SimpleTagSupport class.
>
> See:
>
> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/SimpleTagSupport.html
> http://www.sitepoint.com/print/jsp-2-simple-tags - very simple tutorial.
>
> I think tomcat 5.x comes bundled with basic examples you should be able
> to find examples in webapp jsp-examples.
> Look in folder TOMCAT_HOME\webapps\jsp-examples\jsp2\simpletag for
> HelloWorldSimpleTag.java.html
>
> Thanks,
> Vijay Venkataraman
>
>
> Bart Busschots wrote:
>
> > Anything you can do with a font tag you can do with CSS. In this day
> > and age no one should be using font tags anymore!
> >
> > Bart.
> >
> > Pankaj Gupta wrote:
> >
> >> I dont think CSS can work in this case as the CSS would be static. I
> >> want to display color of the font based on the value of severity of
> >> message i.e. if the message is critical it should be displayed in
> >> red, info in blue, etc. i.e. It would depend on the value of a form
> >> bean property.
> >>
> >> Li wrote:
> >>
> >>> why not use CSS?
> >>>
> >>> On 7/17/06, Pankaj Gupta <pa...@hsc.com> wrote:
> >>>
> >>>>
> >>>> Hi All,
> >>>>
> >>>> I want to create a custom tag which wraps the plain html font tag in
> >>>> such a way that it fetches the color of the font to be displayed on a
> >>>> pre-configured severity level. Can anyone pl suggest how can I do
> >>>> that.
> >>>>
> >>>> regards,
> >>>> Pankaj
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>> For additional commands, e-mail: user-help@struts.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
> ------------------------------DISCLAIMER------------------------------
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any mistransmission.
>
> If you receive this message in error, please immediately delete it and
> all copies of it from your system, destroy any hard copies of it and
> notify the sender. You must not, directly or indirectly, use, disclose,
> distribute, print, or copy any part of this message if you are not the
> intended recipient.
>
> Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each
> reserve the right to monitor all e-mail communications through its
> networks.
>
> Any views expressed in this message are those of the
> individual sender, except where the message states otherwise and the
> sender is authorized to state them to be the views of any such entity.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
When we invent time, we invent death.

Re: How to create custom tag

Posted by vijay venkataraman <vi...@ltp.soft.net>.
Font Tag is deprecated see 
http://www.w3.org/TR/html401/present/graphics.html#edef-FONT
If you are on JSP 2.0  it is very easy to write a Tag yourself. Just 
override doTag() method of SimpleTagSupport class.

See:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/SimpleTagSupport.html
http://www.sitepoint.com/print/jsp-2-simple-tags - very simple tutorial.

I think tomcat 5.x comes bundled with basic examples you should be able 
to find examples in webapp jsp-examples.
Look in folder TOMCAT_HOME\webapps\jsp-examples\jsp2\simpletag for  
HelloWorldSimpleTag.java.html

Thanks,
Vijay Venkataraman


Bart Busschots wrote:

> Anything you can do with a font tag you can do with CSS. In this day 
> and age no one should be using font tags anymore!
>
> Bart.
>
> Pankaj Gupta wrote:
>
>> I dont think CSS can work in this case as the CSS would be static. I 
>> want to display color of the font based on the value of severity of 
>> message i.e. if the message is critical it should be displayed in 
>> red, info in blue, etc. i.e. It would depend on the value of a form 
>> bean property.
>>
>> Li wrote:
>>
>>> why not use CSS?
>>>
>>> On 7/17/06, Pankaj Gupta <pa...@hsc.com> wrote:
>>>
>>>>
>>>> Hi All,
>>>>
>>>> I want to create a custom tag which wraps the plain html font tag in
>>>> such a way that it fetches the color of the font to be displayed on a
>>>> pre-configured severity level. Can anyone pl suggest how can I do 
>>>> that.
>>>>
>>>> regards,
>>>> Pankaj
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


------------------------------DISCLAIMER------------------------------
This message is for the named person's use only. It may contain 
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission. 

If you receive this message in error, please immediately delete it and 
all copies of it from your system, destroy any hard copies of it and 
notify the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the 
intended recipient. 

Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each 
reserve the right to monitor all e-mail communications through its 
networks. 

Any views expressed in this message are those of the 
individual sender, except where the message states otherwise and the 
sender is authorized to state them to be the views of any such entity.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to create custom tag

Posted by Bart Busschots <ba...@so-4pt.net>.
Anything you can do with a font tag you can do with CSS. In this day and 
age no one should be using font tags anymore!

Bart.

Pankaj Gupta wrote:
> I dont think CSS can work in this case as the CSS would be static. I 
> want to display color of the font based on the value of severity of 
> message i.e. if the message is critical it should be displayed in red, 
> info in blue, etc. i.e. It would depend on the value of a form bean 
> property.
>
> Li wrote:
>> why not use CSS?
>>
>> On 7/17/06, Pankaj Gupta <pa...@hsc.com> wrote:
>>>
>>> Hi All,
>>>
>>> I want to create a custom tag which wraps the plain html font tag in
>>> such a way that it fetches the color of the font to be displayed on a
>>> pre-configured severity level. Can anyone pl suggest how can I do that.
>>>
>>> regards,
>>> Pankaj
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to create custom tag

Posted by Pankaj Gupta <pa...@hsc.com>.
I dont think CSS can work in this case as the CSS would be static. I 
want to display color of the font based on the value of severity of 
message i.e. if the message is critical it should be displayed in red, 
info in blue, etc. i.e. It would depend on the value of a form bean 
property.

Li wrote:
> why not use CSS?
>
> On 7/17/06, Pankaj Gupta <pa...@hsc.com> wrote:
>>
>> Hi All,
>>
>> I want to create a custom tag which wraps the plain html font tag in
>> such a way that it fetches the color of the font to be displayed on a
>> pre-configured severity level. Can anyone pl suggest how can I do that.
>>
>> regards,
>> Pankaj
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to create custom tag

Posted by Li <am...@gmail.com>.
why not use CSS?

On 7/17/06, Pankaj Gupta <pa...@hsc.com> wrote:
>
> Hi All,
>
> I want to create a custom tag which wraps the plain html font tag in
> such a way that it fetches the color of the font to be displayed on a
> pre-configured severity level. Can anyone pl suggest how can I do that.
>
> regards,
> Pankaj
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
When we invent time, we invent death.