How to load images and fragments dynamically in Li

2020-08-04 09:25发布

I've created a couple of shared templates (.xdp) which will be shared among several clients. Obviously, each client has their own logo and I'd like to set the logo upon form generation.

I've managed to change the logo dynamically although I'm not sure if my approach is good.

In the xml datasource I've got this element:

<ClientID>SomeNumber</ClientId>

In the form itself I set the image href with this javascript code:

SomeHiddenTextField::calculate
HeaderLogo.value.image.href = $record.ClientID + "_logo.jpg";

I've got the logos stored on the server in the same folder as the shared templates.

Is this an alright approach to load logos dynamically?

I've been trying to achieve the same dynamic behaviour with each client's footer fragment, but I have been unable to figure out how to load these on demand. I could make each footer fragment in to an image but I'd like to avoid it if possible.

1条回答
别忘想泡老子
2楼-- · 2020-08-04 10:06

I know generally for loading images dynamically I had to do the following:

Create a SOAP service that returns a byte[] with the image data (base64)

Call the service from LiveCycle:

var cURL = "http://host/path/MyService?wsdl"
var oService = SOAP.connect(cURL);
try {
    var cText = "";
    var myRequest;
    var cSOAPAction;
myRequest = { 
 myMethod: { 
 Param1:value
 };
cSOAPAction= "http://mynamespace/myMethod";
}
    var myNamespace = "http://mynamespace";

    var oResults = SOAP.request ({
        cURL: cURL,
        oRequest: oGetNameByIdRequest,
        cAction: cSOAPAction,
        bEncoded: false,  // If false then document/literal encoding will be used.
        cNamespace: myNamespace,
        cResponseStyle: SOAPMessageStyle.Message
    }); 
    HeaderLogo.rawValue = oResults[0].soapValue[0].soapValue;
...
查看更多
登录 后发表回答