You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Craig Berry <Cr...@portblue.com> on 2004/03/24 03:46:32 UTC

bean:message inside onclick javascript string?

I have a webpage on which I do a Javascript popup to confirm a deletion.
The JSP fragment looks like this:

<html:submit property="command" value="Delete"
  onclick="return confirm('Are you sure you want to delete this
paragraph permanently?')"/>

I would dearly love to replace that fixed text with <bean:message
key="confirm.paragraph.delete"/>, but all my experimentation has not
succeeded in finding a relatively straightforward way to do this.  I'm
using the -el taglibs, if that matters.  Anybody have ideas on an
elegant solution?

-- 
Craig Berry
Principal Architect and Technical Manager
PortBlue
(310) 566-7546
 

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


Re: Form's property, String or not?

Posted by Xuemin Guan <xu...@bbx-japan.com>.
Thanks, Andrew, it explains very well.

Xuemin

----- Original Message ----- 
From: "Andrew Hill" <an...@gridnode.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, March 24, 2004 12:33 PM
Subject: RE: Form's property, String or not?


> For actionforms you should make them all strings. Certainly anything that
> allows for text entry in the UI should be made a string even if it is
> intended for numeric input. (For checkboxes and such like its less
important
> though Id still recommend using strings for them)
>
> This allows you to return the user to the form when validation fails with
> the input they entered preserved - so if they type "One" instead of "1"
the
> bad value will be preserved for them to correct on return to the page.
>
> If they type text into a field whose actionform property is numeric you
can
> have problems handling it. I cant remember if it causes an exception or is
> just converted implicitly to the value 0 - but either way its a problem...
>
> -----Original Message-----
> From: Xuemin Guan [mailto:xuemin.guan@bbx-japan.com]
> Sent: Wednesday, 24 March 2004 11:30
> To: Struts Users Mailing List
> Subject: Form's property, String or not?
>
>
> Hi, dear all, very new to Struts. Just a simple question:
>
> As a best practice of Struts,  should I declare formebeans'
> properties all as String, or the "actual" type (such as BigDecimal,
> int, float, and double etc.)
>
> Thanks,
>
> Xuemin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


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


RE: Form's property, String or not?

Posted by Andrew Hill <an...@gridnode.com>.
For actionforms you should make them all strings. Certainly anything that
allows for text entry in the UI should be made a string even if it is
intended for numeric input. (For checkboxes and such like its less important
though Id still recommend using strings for them)

This allows you to return the user to the form when validation fails with
the input they entered preserved - so if they type "One" instead of "1" the
bad value will be preserved for them to correct on return to the page.

If they type text into a field whose actionform property is numeric you can
have problems handling it. I cant remember if it causes an exception or is
just converted implicitly to the value 0 - but either way its a problem...

-----Original Message-----
From: Xuemin Guan [mailto:xuemin.guan@bbx-japan.com]
Sent: Wednesday, 24 March 2004 11:30
To: Struts Users Mailing List
Subject: Form's property, String or not?


Hi, dear all, very new to Struts. Just a simple question:

As a best practice of Struts,  should I declare formebeans'
properties all as String, or the "actual" type (such as BigDecimal,
int, float, and double etc.)

Thanks,

Xuemin


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



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


Form's property, String or not?

Posted by Xuemin Guan <xu...@bbx-japan.com>.
Hi, dear all, very new to Struts. Just a simple question:

As a best practice of Struts,  should I declare formebeans'
properties all as String, or the "actual" type (such as BigDecimal,
int, float, and double etc.)

Thanks,

Xuemin


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


Re: bean:message inside onclick javascript string?

Posted by Saul Q Yuan <yu...@dataanvil.com>.
Try move the onclick javascript function out, something like this:


<script language="javascript">

    function verify() {
        var msg = "<beam:message key="confirm.paragraph.delete" />";

        return confirm(msg);
    }
</script>


<html:submit property="command" value="Delete"
  onclick="return verify();"/>


Saul
  ----- Original Message ----- 
  From: Craig Berry 
  To: struts-user@jakarta.apache.org 
  Sent: Tuesday, March 23, 2004 9:46 PM
  Subject: bean:message inside onclick javascript string?


  I have a webpage on which I do a Javascript popup to confirm a deletion.
  The JSP fragment looks like this:

  <html:submit property="command" value="Delete"
    onclick="return confirm('Are you sure you want to delete this
  paragraph permanently?')"/>

  I would dearly love to replace that fixed text with <bean:message
  key="confirm.paragraph.delete"/>, but all my experimentation has not
  succeeded in finding a relatively straightforward way to do this.  I'm
  using the -el taglibs, if that matters.  Anybody have ideas on an
  elegant solution?

  -- 
  Craig Berry
  Principal Architect and Technical Manager
  PortBlue
  (310) 566-7546
   

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