Trying to set the class of an XPage UL based on underlying document?

Please excuse this if it seems like a very basic question - I am trying my best to “catch up” to all the XPages professionals out there!

I have a custom control that contains an unordered list (UL).

That UL has a default class associated with it in the HTML (source) code.

I would like to change the class associated with that UL when the control is loaded, based on a field value retrieved from the underlying document.

Typically, I have been able to perform the dynamic association of classes with other elements in the control (e.g. tables), but those are all known to XPages.

In those cases, I can calculate the className value with script by clicking on the “diamond” next to the parameter.

Unfortunately, a “UL” element is not natively known to XPages, and that diamond is not available.

I believe I need to use client-side script to retrieve the document value, and then get a handle to the UL element and change the class.

I think I can handle that, but where do I place the code? Historically, I would embed some calculated text in a script block on a form/page, and call that when the page was loaded (onLoad).

I’m just not as familar as I should be with the new environment, and need a push in the right direction in this case.

Is anyone able to provide me with some assistance?

Thanks for any help you may be able to give!

T.

Subject: Re: dynamic ul class

Another option is to use a Computed Field control to pass the HTML onto your XPage. A Computed Field control can have the Content Type set to HTML (or parameter escape=“false” in the source panel), kind of like pass-thru HTML on a Notes form.

So you compute the output of your Computed Field control using server-side javascript to get the underlying document and the class and write that along with your ul tag, so e.g.

var class=document1.getItemValueString(“ClassName”)

return “

    You may need another Computed Field Control to close your ul afterwards, I’m not sure if the source panel will accept it written on the XPage.

Subject: Thanks Paul!

Thanks very much Paul - That was exactly what I needed!

I knew it was staring me straight in the face - I just need more experience with the new environment.

You were right BTW… I did need to script the closing “

    ” tag.

    Thanks again - I should’ve asked earlier before spending a few hours attempting more “imaginative” solutions!

    Cheers, T.

Subject: Or you can compute the HTML attribute

You can compute attributes in HTML placed in XPages.

Designer doesn’t give you a “compute value” option with JavaScript editor dialog,

so you have to type it in manually, or compute the value in a standard XPages control

and copy it to the HTML element.

<ul style="#{javascript: 'border:blue solid thin' }">

	<li>item</li>

</ul>