Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2007-02-21 02:38:12

joshna
New member
Registered: 2007-02-06
Posts: 8

xinha not working in a jsf application

Hi

I am trying to use xinha editor in my jsf application .But the editor is not loading.

Does Xinha work with jsf.If so please send me the sample code .If not are there any plans to support it in the future.

Thanks alot in advance

-joshna
mail id: Joshna.Kambalapalli@Sun.COM

Offline

#2 2007-02-21 08:01:54

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: xinha not working in a jsf application

This should really not be the case!
Xinha should work with any server technology, provided
  - all files can be loaded by the browser
  - the xinha_init function is executed onload (this could be an issue if jsf or any other script overwrites the window.onload property)

Could you give a URL to a page where you have set up Xinha and which is not working. I'm sure we can work it out

Offline

#3 2007-02-21 09:03:44

joshna
New member
Registered: 2007-02-06
Posts: 8

Re: xinha not working in a jsf application

Thanks a lot for the response ray.

I have the installation on my local machine which is behind the firewalls which cannot  be viewed from outside.

I will try to explain

The following is my jsf code which is trying to embed the xinha

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">         
                      <head>   <script>
         _editor_url  = "../xinha/";
         _editor_lang = "en";
         _editor_skin = "blue-metallic";
                          </script>
                          <script type="text/javascript" src="../xinha/htmlarea.js"></script>
                         
                         
                          <script type="text/javascript">
  xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;
   
      xinha_init = xinha_init ? xinha_init : function()
    {
    xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
    if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;
  xinha_editors = xinha_editors ? xinha_editors :
      [
        'newbiearea1'
      ];

     
       xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config();
       
             xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
HTMLArea.startEditors(xinha_editors);
    }

    window.onload = xinha_init;
                          </script>
                      </head>
                      <f:view>
                          <body>
                            <h:inputTextarea id="newbiearea1" rows="10" cols="50"  style="width: 100%" />
                             
                             
                             
                          </body>
                      </f:view>
 

The same code is working fine excluding those jsf tags.The following is the code which is working after excluding jsf tags


<!DOCTYPE BHTML PUBLIC "-//BC//DTD BHTML 3.2 Final//EN">
<html>
    <head>   <script>
         _editor_url  = "../xinha/";
         _editor_lang = "en";
         _editor_skin = "blue-metallic";
        </script>
        <script type="text/javascript" src="../xinha/htmlarea.js"></script>
       
       
        <script type="text/javascript">
  xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;
   
      xinha_init = xinha_init ? xinha_init : function()
    {
    xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
    if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;
  xinha_editors = xinha_editors ? xinha_editors :
      [
        'newbiearea1'
      ];

     
       xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config();
       
             xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
HTMLArea.startEditors(xinha_editors);
    }

    window.onload = xinha_init;
        </script>
    </head>
   
    <textarea id="newbiearea1" name="newbiearea1" rows="10" cols="50" style="width: 100%"></textarea>
</html>


please help me in resolving this issue.
Thanks
joshna
Joshna.Kambalapalli@Sun.COM

Offline

#4 2007-02-21 11:24:58

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: xinha not working in a jsf application

Knowing nothing about jsf (but a quick google search), I have to guess:

Please open the page in your browser and select "View Source":

<h:inputTextarea id="newbiearea1" rows="10" cols="50"  style="width: 100%" />

may have turned into somthing like

<textarea id="someStuffByJsfProbablyFormId:newbiearea1" rows="10" cols="50"  style="width: 100%"></textarea>

if it's like this, the xinha_editors array contains the wrong id and Xinha cannot find the appropriate textarea.

Have a look at the piece of code below, which tries to transform the given id's into the actual ones (supposing it's the form id that is prefixed)

xinha_init = xinha_init ? xinha_init : function()
{
  xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
  if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;
  
  var JsfInputTextareaIds  =  [ 'newbiearea1' ];
  function getRealIds (ids)
  {
    var realIds = [];
    var tas = document.getElementsByTagName("textarea");
    for (var i=0;i<ids.length;i++)
    {
      for (var j=0;j<tas.length;j++)
      {
        if ( tas[j].id == tas[j].form.id+':'+ids[i] )
        {
          realIds.push(tas[j].id);
        }
      }
      return realIds;
    }
    xinha_editors = getRealIds(JsfInputTextareaIds);

    xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config();

    xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
    HTMLArea.startEditors(xinha_editors);
  }
}

Offline

#5 2007-02-22 11:21:16

joshna
New member
Registered: 2007-02-06
Posts: 8

Re: xinha not working in a jsf application

Thanks a lot for the help ray.

It was only because jsf appends an id in front of all the fields.

I got it working .But I didnt understand what will the java script function getRealIds(ids) will do.

-joshna

Offline

Board footer

Powered by FluxBB