You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Vineet T <vi...@tcs.com> on 2008/01/21 10:29:24 UTC

Reg:Html code not working with .jspx page

I am using xmlns:trh="http://myfaces.apache.org/trinidad/html"

and also using   xmlns:h="http://java.sun.com/jsf/html" in my
.jspx page. The html code written is working fine stand alone
in .html file but the same code not working in .jspx file.

Code for that is given below.


<script type="text/javascript">
 
                                        function formatOnKeyPress(element)
{
                                                      var 
value=element.value;
                                                      var limit = new 
Array(6,2);
                                                      var c = 
String.fromCharCode(window.event.keyCode);
                                                          value = 
value.replace(/^\s+/, "").replace(/\s+$/, "" );
                                                      if
(/\d/.test(c)&amp;&amp;(/\./.test(value)?/^.*\.\d?$/.test(value):(!value||value.match(/\d/g).length&lt;6)))
{
                                                            value= 
/^[^\.]*$/.test(value)?/^.*\,?\d{3}$/.test(value)?value+",":value:value;
 element.value=value; 
                                                            return true;
                                                      }else if
(/[\.\,]/.test(c)&amp;&amp;!/\./.test(value)){
                                                            return true;
                                                      }else{
                                                            return false;
                                                      } 
                                                }

</script>

<h:inputText id="txtBalance" maxlength="10"
        value="#{MyBean.adjustBal}"
        styleClass="InputText" onkeypress="return formatOnKeyPress(this);" 
/>


reply as soon as possible.
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Re: Reg:Html code not working with .jspx page

Posted by Andrew Robinson <an...@gmail.com>.
This is not a dev question, please use the users list for all user
questions.

Could you tell us what is not working? Please look at the generated source
and let us know what is wrong.

It could be that you are using jspx, which is XML, but you javascript is not
valid XML. In xhtml pages with facelets I know that it is required to put
the JS in CDATA blocks:

<script>
// <![CDATA[
...code...
// ]]>

On Jan 21, 2008 2:29 AM, Vineet T <vi...@tcs.com> wrote:

>
> I am using xmlns:trh="http://myfaces.apache.org/trinidad/html"
>
> and also using   xmlns:h="http://java.sun.com/jsf/html" in my
> .jspx page. The html code written is working fine stand alone
> in .html file but the same code not working in .jspx file.
>
> Code for that is given below.
>
>
> <script type="text/javascript">
>
>                                         function formatOnKeyPress(element)
> {
>                                                       var value=
> element.value;
>                                                       var limit = new
> Array(6,2);
>                                                       var c =
> String.fromCharCode(window.event.keyCode);
>                                                           value =
> value.replace(/^\s+/, "").replace(/\s+$/, "" );
>                                                       if
> (/\d/.test(c)&amp;&amp;(/\./.test(value)?/^.*\.\d?$/.test(value):(!value||value.match(/\d/g).length&lt;6)))
> {
>                                                             value=
> /^[^\.]*$/.test(value)?/^.*\,?\d{3}$/.test(value)?value+",":value:value;
>
> element.value=value;
>                                                             return true;
>                                                       }else if
> (/[\.\,]/.test(c)&amp;&amp;!/\./.test(value)){
>                                                             return true;
>                                                       }else{
>                                                             return false;
>                                                       }
>                                                 }
>
> </script>
>
> <h:inputText id="txtBalance" maxlength="10"
>         value="#{MyBean.adjustBal}"
>         styleClass="InputText" onkeypress="return formatOnKeyPress(this);"
> />
>
>
> reply as soon as possible.
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
>