1 Reply Latest reply on Feb 21, 2007 5:58 PM by Elias Ross

    JBOSS SEAM  and JavaScript

    Andreas Pesel Newbie

      Hello to everyone!

      I'm a bloody Jboss novice - the only thing already now are Java itself and JSP's.
      Right now I need to learn JBOSS Seam in connection with hibernate for a school project.

      The installation and development of my project is fine, everything works.
      But my problem is the following:

      I need a javascript on my site. I know that there is the possibility of using AJAX and JSF components, but I've found nothing that matches my need.

      I need a counter which counts from e.g. 160 down to 0 in an inputText depending on how many characters the users has written in the textarea.

      So I thought that it might work if I put the javascript itself hardcoded onto my site - but it doesn't. There is no error message or anything else that is shown. The JavaSCript itself works fine in a normal HTML site.

      So here is my code:

      I've a template.xhtml where i puttet the javascript between the header tags:

      <script type="text/javascript">
      function pruef (chars) {
       var anz=0, len=0,s;
       var msg = document.predefines.predefines:nachr.value;
       if (!chars) {
       chars = 151;
       for (var i=0; i < msg.length; i++) {
       s = msg.charAt(i);
       if (s=='?' || s=='~' || s=='^' || s=='\\' || s=='{' || s=='}' || s=='[' || s==']' || s=='|') {
       if (anz>(chars-2)) {
       } else if (s=="\r") {
       } else {
       if (anz>(chars-1)) {
       len = i+1;
       if (msg.length> len) {
       document.predefines.predefines:nachr.value = msg.substring(0,len);
       document.predefines.predefines:num.value = chars-anz;
       if (navigator.appName =="Netscape" && parseInt(navigator.appVersion) <= 4){
       document.predefines.predefines:nachr.onkeypress = pruef;

      and then i just called the function on the site i need:

      <h:form id="predefines">
       <h:inputTextarea id="nachr" onkeyup="pruef(160);" cols="50" rows="5"/>
       <h:inputText value="160" id="num" onfocus="this.blur();"/>

      I hope you can help me!