1
votes

I am tryng to get a photo in another database to display as an icon in a repeat control column. I just can't find a way to make it work. I do get a handle on the document the photo is stored in and tried all sorts of ways to get it to work.

I want the icon to display where is in code below

Here is my code.

    <div class="panel-body">
        <xp:panel styleClass="form-group" tagName="div">
            <xe:widgetContainer id="widgetContainer2"
                titleBar="false">
                <!-- Show pager controls at top-->
                <xp:this.rendered><![CDATA[#{javascript:view1.getAllDocumentsByKey(session.getEffectiveUserName()).getCount().toFixed()>0}]]></xp:this.rendered>
                <xp:panel id="topControls" styleClass="row topPager">

                    <div class="col-sm-12">
                        <xp:pager layout="Previous Group Next" partialRefresh="true"
                            id="pager1" for="repeat1" styleClass="pull-right">
                        </xp:pager>
                    </div>
                </xp:panel>
                <!-- Show table with Data -->
                <xp:panel id="details" styleClass="col-md-12">
                    <div id="resultsDiv">
                        <table class="table table-condensed">
                            <thead>
                                <tr>
                                    <th style="width 5px">
                                    </th>
                                    <th style="width: 70px;">
                                        <xp:text escape="true" id="computedField18" tagName="label"
                                            value="${langBean.MyAttachTableNickName}">
                                        </xp:text>
                                    </th>
                                    <th style="width: 10px;">
                                        <xp:text escape="true" id="computedField5" tagName="label"
                                            value="${langBean.MyAttachTableSerialNbr}">
                                        </xp:text>
                                    </th>
                                    <th style="width: 70px;">
                                        <xp:text escape="true" id="computedField1" tagName="label"
                                            value="${langBean.MyAttachTableModelNbr}">
                                        </xp:text>
                                    </th>
                                    <th style="width 70px"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <xp:repeat id="repeat1" var="rowData" indexVar="ind"
                                    value="#{view1}" rows="10" repeatControls="true">
                                    <tr>
                                        <td>
                                            <xp:text escape="false">
                                            </xp:text>
                                            <xe:multiImage>
                                                <xe:this.value><![CDATA[#{javascript:importPackage (com.cascorp);
var url
var photoURL
if(rowData.isDocument()){
    var iconName = rowData.getDocument().getItemValue("icon")
    var whURL = configBean.getValue("WorkHorseURL")
    var whDbPath = configBean.getValue("WorkHorseDbPath")
    var hostURL = configBean.HostURL
    var db: NotesDatabase = session.getDatabase("",whDbPath, false)
    //get document in whdb
    var v1:NotesView = db.getView("fsSmlu")
    var v2:NotesView = db.getView("attachmentImagesSmall")
    var whDoc:NotesDocument = v1.getDocumentByKey(iconName);
    if(whDoc == null){
    dBar.info("whDoc is null")
    } else {
    var itemValue = whDoc.getItemValueString("smKey")
    var imageDoc:NotesDocument = v2.getDocumentByKey(itemValue)
    }
    photoURL="/"+imageDoc.getUniversalID()+"/RTF/0.84?OpenElement&FieldElemFormat=jpg"
})
    try{
    url=configBean.HostURL+configBean.WorkHorseURL+photoURL
    dBar.info("URL >>> " +url)
    }catch (e){
    dBar.info("ERROR: "+ e.toString())
    return e.toString()
    }
    return url
}  else {
dBar.info("rowData is not document")
}
}]]>

</xe:this.value>
                                                    <xe:this.icons>
                                                        <xe:iconEntry
                                                            url="#{viewScope.photoURL}">
                                                        </xe:iconEntry>
                                                    </xe:this.icons>

                                            </xe:multiImage>
                                        </td>
                                        <td>
                                            <xp:text escape="true" value="#{rowData.Attachment}"
                                                id="computedield12" value="#{rowData.serialNbr}">
                                            </xp:link>
                                        </td>
                                        <td>
                                            <xp:text escape="true" id="computedField6" value="#{rowData.serialNbr}">
                                            </xp:text>
                                        </td>
                                        <td>
                                            <xp:text escape="true" id="computedField2" value="#{rowData.modelNbr}">
                                            </xp:text>
                                        </td>
                                    </tr>
                                </xp:repeat>
                            </tbody>
                        </table>
                    </div>
                </xp:panel>


                <!-- Footer row with pager -->
                <xp:panel id="panel7" styleClass="row">
                    <div class="col-sm-12">
                        <xp:pager layout="Previous Group Next" partialRefresh="true"
                            id="pager4" for="repeat1" styleClass="pull-right">
                        </xp:pager>
                        <xe:pagerSizes id="pagerSizes1" for="repeat1"
                            text="${langBean.pagerSizesPretext} {0} #{langBean.pagerSizesPosttext}">
                        </xe:pagerSizes>
                    </div>
                </xp:panel>
            </xe:widgetContainer>
        </xp:panel>
    </div>
</xe:widgetContainer>

What am I doing wrong?

1
Where is viewScope.photoURL defined?Per Henrik Lausten
As Per says, can't see where you are defining the viewScope variable.... Also, what value do you get from from the URL variable in the dBar? Is it returning the URL as expected?Chris Richards

1 Answers

1
votes

Mike, first off the following codeblock produces a "Attribute 'value' already specified error and will keep your code from compiling:

                    <td>
                        <xp:text escape="true" value="#{rowData.Attachment}" id="computedield12" value="#{rowData.serialNbr}">
                        </xp:link>
                    </td>

For the photo issue you are using an xe:multiImage control improperly here. The xe:multiImage is used to conditionally display one or another image. Yours has only one xe:iconEntry defined and you are not calling it correctly as it has no selectedValue attribute.

Instead, replace the xe:multiImage code with an xp:image control to display the single photo:

            <xp:image id="image1">
                <xp:this.url><![CDATA[#{javascript:
                    var url = "";
                    // add code here to return url to image to display 
                    //
                    // then
                    return url ;}]]>
                 </xp:this.url>
            </xp:image>