Tree definition in checkBoxTree

Hi,
I’m trying to create a checkBoxTree with dynamic value that are loaded by an internal lookup query. That part I don’t know how to do is the tree definition ? It would be easy to do with static value but how can I define that tree with dynamic values ?

Regards,

Guillaume

Hi,

There is some evolution on my problem. I created another internal lookup query for the tree definition but it still not working. I think that my problem is on the call of that internal query definition because when I copy the result document in a file and call the file instead of the query definition for the tree definition, the chexkBoxTree work fine.

See attachment for the call of my query definition.

Here is a copy of the result of my lookup query :

<?xml version="1.0" encoding="utf-8"?>
<sys_Lookup>
	<PSXEntry>
		<PSXDisplayText>Lennon, John</PSXDisplayText>
		<Value>1001</Value>
	</PSXEntry>
	<PSXEntry>
		<PSXDisplayText>Marcoux, Jean-Sébastien</PSXDisplayText>
		<Value>1027</Value>
	</PSXEntry>
	<PSXEntry>
		<PSXDisplayText>Roy, Vital</PSXDisplayText>
		<Value>1028</Value>
	</PSXEntry>
	<PSXEntry>
		<PSXDisplayText>St-Louis, Marc</PSXDisplayText>
		<Value>979</Value>
	</PSXEntry>
	<PSXEntry>
		<PSXDisplayText>Trottier, Guillaume É.</PSXDisplayText>
		<Value>980</Value>
	</PSXEntry>
</sys_Lookup>

Here is a copy of the result of my tree def query :

<?xml version="1.0" encoding="utf-8"?>
<tree label="HEC">
	<node id="profs" label="Professeurs" selectable="no">
		<node id="1001" label="Lennon, John" selectable="yes"/>
		<node id="1027" label="Marcoux, Jean-Sébastien" selectable="yes"/>
		<node id="1028" label="Roy, Vital" selectable="yes"/>
		<node id="979" label="St-Louis, Marc" selectable="yes"/>
		<node id="980" label="Trottier, Guillaume É." selectable="yes"/>
	</node>
</tree>

Regards,

Guillaume

Guillaume,

I’m not sure I understand exactly what you’re trying to do.

In a checkbox tree field, there are 2 important parameters related to selection:

  1. a “treesourceurl”, which is there the <tree> and <node> xml comes from

  2. a set of “choices”, which is in the <PSXEntry> format.

All of the ids in the tree MUST be in the choices, or the values will be removed when a validation failure happens.

There is insufficient informationin the “choices” xml, so you cannot make the tree from the choices, but there is enough information in the tree to make the choices.

You can use XSLT to turn a tree into choices, if that’s what you’re trying to do.

It’s also possible to create a tree from a set of database queries (again, using XSLT), but this will require a highly computational stylesheet. If you’ve read Michael Kay’s book, this is slightly less complicated than his “knight’s tour” example (and so not for the faint of heart).

Tell me more about where the data comes from, and I can give you more suggestions about how to turn it into the 2 formats.

Dave

Hi Dave,

I created 2 internal querys. One for the “choices” (lookup dtd) and one for the “treesourceurl” (with a xslt to format my xml). My problem is that I am unable to pass a parameter to the “treesourceurl” query. I nead to pass the user “sys_lang” to that query. When I’m calling the tree_src_url with a literal like “…/hec_Support/prof_tree” it work fine but then I have to hard code the locale in my query. I’m trying to pass the locale of the user in the parameter using the sys_MakeIntLink function with paramName1 = sys_lang paramValue1 = “User/SessionObject/sys_lang” and then it does not work. My “choices” query is working that way to and I did not have any difficulty with it.

Do you have any idea how to make that work ?

Regards,

Guillaume

Guillaume,

I had no trouble setting this on my system.

I added a link to an existing application and set the first parameter name to “sys_lang”. For the value, I selected “UserContext” (NOT “Literal”) and then “User/SessionObject/sys_lang”.

Here’s the resulting fragment from the control XML…

<Control accessKey="" dataType="sys_local" dimension="array" isReadOnly="no" isRequired="no" name="sys_CheckBoxTree" paramName="segments">
   <ParamList>
        <Param name="tree_src_url">http://127.0.0.1:9222/Rhythmyx/rx_Support_pub/itemstatus?sys_lang=en-us</Param>
    </ParamList>
</Control>

Of course, I didn’t actually pass this to the treecontrol to see what it does with the URL.

Are you seeing the sys_lang parameter in the Content Editor XML, or not ?

Dave

Hi Dave,

I have the same resault as you in the Content Editor XML but when I want to create an item, the checkBoxTree is not showing.

Guillaume

Hi Dave

All of the ids in the tree MUST be in the choices, or the values will be removed when a validation failure happens.

I thought the choices XML file only contained those items that the user has selected. If it meant to contain all id then how is this presented in the file?

I have a checkboxtree control which renders and saves OK but if validation fails then the users selection is lost.

Cheers
James

It is meant to contain all of the possible choices, not just the selected choices.

The selected choices are the “values” of the field, represented as a delimited list. This is passed to the checkboxtree applet through a different parameter.

Dave

Very strange. I don’t, of course, have your setup here, so it’s hard for me to know exactly what’s wrong.

You said it works when you add a hardcoded URL for the treesource. Does it also work when you supply a hardcode Locale parameter:

…/hec_Support/prof_tree?sys_lang=ca-fr

Dave

Hi,
No it don’t. It is like if the parameter never work.

I’ll try to use another function to pass my parameter and will let you know if I find something.

If you have any idea please let me know.

Regards,

Guillaume

Guillaume,

If a “hardcode” parameter doesn’t work, then other functions you might add won’t work either. Are you using the standard Applet? What version (and patch level) is this?

Also, is it the “locale” of the user you are trying to match or the locale of the content item you are editing?

Dave

Hi Dave

so the tree_src_url should point to an xml file or application resource to generate the structured XML

the choices tab (retrieve from xml application) should point to an application that lists all the items in the structured XML but conform to the sys_Lookup DTD

This is passed to the checkboxtree applet through a different parameter.

Where is this set?

Sorry to be asking these question but the technical ref manual is not clear on the checkboxtree control.

Cheers
James

Hi,
Yes I’m using the standar Applet. We are on Rx 6.5.2 [13195]. I’m trying to pass the user locale.

I’m now using the function “sys_MakeAbsLink” to call my application for the “tree_src_url” parameter. The sys_lang is now passing. It’s always work with IE but sometime with Firefox it is asking my to login :confused:

Is this a bug ?

Guillaume

I guess I’m confused too. You said it wasn’t working when you passed a parameter, and now it is working? Could you elaborate?

If you have problems with requests for a login, you can always try adding the session id parameter to the link in the call to MakeAbsLink

This name of this parameter is always “pssessionid” and you get the value from
the “UserContext” (just as you do the user’s locale).

Dave

[QUOTE=jimbo;2778]Hi Dave

so the tree_src_url should point to an xml file or application resource to generate the structured XML

the choices tab (retrieve from xml application) should point to an application that lists all the items in the structured XML but conform to the sys_Lookup DTD

Where is this set?

[/QUOTE]

Your assumptions are correct. The XSL template for the checkboxtree control computes the selected values and passes them to the applet as the “selectedItems” parameter.

You can look at the control definition in /Rhythmyx/sys_resources/stylesheets/sys_Templates.xsl for more details.

Dave

Hi Dave,

The default function is “sys_MakeIntLink”. When I’m using this one with parameter, it does not work. The checkBoxTree is always in error. I change the function to “sys_MakeAbsLink” still with the same parameter and it finally work.

I tested with passing the sessionid to the “sys_MakeAbsLink” function and it did not change anything. Sometime it work with Firefox and sometime it is asking my to reconnect.

Regards,

Guillaume

Guillaume,

sys_MakeIntLink makes an “internal link”. This link always starts with “http://127.0.0.1:…” which means it will only work when the server and the browser are on the same machine. This is almost certainly NOT what you want to do. (BTW, Internal Links include the session id)

sys_MakeAbsLink makes an “absolute link”. This link always starts with “http://<host>:<port>…” (where <host> and <port> are determined from the original request). This link should work, but I’ve not used it with the checkboxtree Applet.

There is a third possibility: use the “sys_MakeLink” function. MakeLink doesn’t re-write the URL, it just uses whatever base you supply. In this case, I’d recommend something that starts with “…/” or perhaps “/Rhythmyx”.

As with MakeAbsLink, you have to select “user defined function” rather than “link” when adding the parameter.

Let me know if this helps

Dave

Hi Dave,

Thanks for the info. I tested it and it work fine now with “sys_MakeLink”. I’m passing the sys_lang and pssessionid parameters and it work with IE and Firefox without asking to reconnect.

Thanks a lot for your help,

Guillaume :smiley:

Hi Dave,
If I’m trying to create a dynamic 3-level checkbox tree from the database, how would the DTD look like. Supposed I copied sys_CheckboxTree.dtd to sys_Checkbox3Level.dtd. I have the backend view working to be mapped to the DTD.

Thanks.
-Oscar