XML Application

So we’re looking to do something with Rhythmyx that we’ve never done before, and wanted to get feedback and advice from anyone who’s done anything similar.

We’re looking to use an XML Application to get data from a database, and map that data to a content item.

The way we’d like to select which record to use in the database, is through a select list, or drop down tree, listing all the possible records.

Once selecting the item, it would populate the content item with all the correct data from the database.

Hopefully that was able to describe what we’re looking to do. Sorry for the poor description.

Thanks,
Nick D

Nick,

I haven’t heard of anyone doing something like this since we released Version 6.0, but I think you could do it. Use a lookup application to populate the dropdown, as you suggest (an example implementation was added to the Version 6.6 Implementation Guide; see “Populating a Field from an External Lookup” on p. 256). Then you could use an extension to call the XML application to populate the data from the remote repository to the other Content Editor fields.

Depending on what you want to do with the data, you might also want to consider adding it to the Template at assembly time using the $rx.ext.call binding function. This function calls an XML application to return data for use in Template assembly.

RLJII

Thanks for the reply RLJ. I forwarded this along to the other developers on our team to see what they think.

We would prefer to use $rx.ext.call as you specified, do we need to define our own custom extension? Can you provide us an example of this function using an XML Application? We would like to pass the value of the drop down (driven by the external lookup) to our XML Application so that it only returns the results that we need. We would then like to bind the results of the XML App to an object we could access in velocity.

Thanks.

Nick,

If you are trying to store the values in a content item, this is done with a content editor, not a content assembler. Velocity and JEXL are only applicable to assemblers, not editors.

To provide a dropdown selection in a content editor, you MUST use an XML application.

XML Applications have their own connection to the database, you don’t need (and cannot use) $rx.ext.call().

If you are trying to DISPLAY values that are in a database, you can use $rx.db.get() to perform the lookup. However, there is no “user interaction”, all of the key information must be stored in the content item.

Since you’ve asked about 2 different things in this thread, perhaps it’s best if you tell which one you are trying to do:

  1. Provide the user with choices during the content editing process

  2. Display information in a template based on keys that are stored in a content item

Dave

Hi Dave,

Thank you for the help, and sorry for the confusion. We’ve been going through different ways to achieve what we’re trying, and I think our descriptions / methods are getting mixed up.

The end goal for us, is this;

We would like to have a content item that has a drop down menu controlled from an XML Application. The result stored in the content item would be an ID.

Then, at assembly time, we want to populate the template with data driven from an external database that would be controlled by the ID stored in the content item.

I hope that makes sense. Please let me know your thoughts.

Nick,

We’ve done something similar at AutoTrader.com to list a huge number of heirarchical choices on the page. Our main bottleneck, though, was the list size, so we had to make a somewhat complex custom control type.

However, if your data size isn’t too large, you can use a simple XML Application in the following manner (essentially what RLJ said, starting on page 259):

In your new XML Application (Workbench->XML Server->Applications) :

[ol]
[li]Create a new “Query Resource” and open it. You should see an image of a pipe with no icons on top of it.
[/li][li]Select your table from the Database Explorer and drag it onto the left side of the pipe. If you don’t have a JDBC connection to your target database, you’ll need to add it.
[/li][li]Insert a new “Selector” and drag it onto the pipe (a little black box should appear on the pipe on the left-most screw-top looking thing if you have it right). the selector icon will snap into place.
[/li][li]Double click on the selector to open it and fill in the query parameters you want to use, then click OK. Personally I usually manually enter the SQL because I find it more granular and easy to manipulate. (Also, sometimes in my install, the display of the typed characters lags a couple keystrokes behind what you type. this can get very frustrating, so if you’re typing the query in, have it built in a text editor and simply paste it in).
[/li][li]Copy the sys_Lookup.dtd from a resource in the sys_ceSupport application and paste it into your new resource’s pipe. Again, drag it around in the window until the little black box appears (on the right of the pipe, this time).
[/li][li]Insert a new Mapper and drag it around in a similar way, then double click on it. Drag 2 table fields (on the left; they can be the same, but don’t have to be) onto the Back-end side of the mapper. Drag “PSXDisplayText” from the DTD (on the right) to the XML column beside the table field you want to use for your label and “Value” to beside the value field. Then click OK and close the pipe editor panel.
[/li][li]Save, close, and restart the XML application.
[/li][/ol]

Back in the Content Editor window:

[ol]
[li]Select your control, and click on “All Properties…”
[/li][li]Click on the “…” button beside the Control field (which should read “sys_DropDownSingle”), then click on the “Choices” tab in the popup.
[/li][li]select “Retrieve from xml application” and click on the “…” button beside the URL field.
[/li][li]choose your Application’s name, and select the resource that you created. If you had variabled in your SQL, you can provite them in the “Params” section.
[/li][/ol]

That should do it.

The query params that you can provide in the control’s URL query can be referenced in a manual SQL statement with the following code: <CODE>:“PSXParam/paramName”</code> - and if you wish to make sure the query doesn’t cause an error when you try to execute it with a missing param, enclose that with single quotes, too… even if you need an integer in your SQL.

I have some code too, that will allow you to populate a custom control with data from an AJAX query that returns JSON-formatted data so that you can chain 4 or 5 controls together to make a drop-down heirarchy that doesn’t take forever and a day to load a huge ammount of data, and samples of how to create such a monster. Let me know if that mess would be helpful as well.

As for retrieving the data in the template, I find it far more direct to use <code>$rx.db.get(‘datasource’,‘sqlQuery’)</code> but to each his own. :slight_smile:

Best Regards,
– Rush

Thanks for the great response Rush. Would you mind sharing more information about your custom control type?

We’re going to have a huge amount of results from the application, but just figured we would live with it…

Thanks!
Nick D