Hello,

I've a problem to integrate and use Javascript in XWiki when I use Class and
Sheet, in 'inline' mode.

I've a second class, called IGCountriesClass, with 2 properties: a static
list called countryzone (contains "EU|AP|LA|NA|WW" for Europe, Asian
Pacific, North America, Latina America and WorldWide) and a string property
called countryname for the country name.

This Class is used to create some documents with format EU/France,
EU/Espagne, EU/Italie, LA/Brasil, etc... to add more countries if needed.

I've also another Class with 2 lists properties (called intergeozone and
intergeocountry), first is static with "EU|AP|LA|NA|WW" like countryzone
from first Class. The second list is a database list property which is
filled with hibernate query "select doc.name, doc.title from
com.xpn.xwiki.doc.XWikiDocument as doc where doc.web = 'EtudeIGCountries'
and doc.name != 'WebHome' order by doc.name"

Well, my problem, I need to control the filling of the second list with
countries belonging to the selected zone in the first list. It's really so
easy to do this with using javascript in normal web use, easy to with xwiki
in 'view' mode but I've a problem to do it with javascript when I go to
'inline' mode.

I use this code in the second Class Sheet, all is ok in 'view' mode but
problem come when I go in 'inline' mode. I get problem with result from
$obj.get(objectname) apparently.

Could someone help me, please? :)

[code]

{{html}}

<!--script type="text/javascript"//-->
function initZone()
{
  var selObj = document.getElementById('countriesSelect');
  selObj.options[0] = new Option('---','');
  selObj.selectedIndex = 0;
}

function changeListe()
{
  choix = document.getElementById("zonesList").value
  populateCountries(choix)
}

function populateCountries(newzone)
{
  var countObj = 0;
  var selObj = document.getElementById('countriesSelect');

  for (var i = 0; i < selObj.options.length; i++)
  {
    selObj.options[i] = null;
  }
  selObj.options.length=null;
  selObj.options[countObj++] = new Option('---','');
  selObj.selectedIndex = 0;

#set ($filespace = "EtudeIGCountries")
#set ($recherche = $xwiki.searchDocuments("where doc.name != 'WebHome' and
doc.space = ? order by doc.name asc",[${filespace}]))
#foreach($entry in $sorttool.sort($recherche))
  #set ($tempdoc = "${entry}")
  #set ($doctemp = $xwiki.getDocument($tempdoc))
  #set ($obj = $doctemp.getObject('EtudeCode.EtudeIGCountriesClass'))
  #set ($entryDoc = $xwiki.getDocument($entry))
  #if($entryDoc.getObject('EtudeCode.EtudeIGCountriesClass'))
if ((newzone == "${obj.get('countryzone')}") || (newzone == "WW"))
{
  selObj.options[countObj++] = new Option("${obj.get('countryname')}",
"${obj.get('countryname')}");
}
  #end
#end
}
</script>

<!--SELECT id="zonesList" onchange="changeListe()" name="zonesList"//-->
#foreach($listitem in $list)
##   * value: $listitem displayed value: $map.get($listitem).getValue()
  #if ($map.get($listitem).getValue() == "NA")
    <OPTION value="$map.get($listitem).getValue()"
SELECTED>$map.get($listitem).getValue()</OPTION>
  #else
    <OPTION
value="$map.get($listitem).getValue()">$map.get($listitem).getValue()</OPTION>
  #end
#end
</SELECT>

<SELECT id="countriesSelect" name="countriesList"></SELECT>
<!--script type="text/javascript">initZone();</script//-->

{{/html}}


[/code]


-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/XWiki-Class-and-Javascript-tp5770427p5770427.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to