Computed Visible property based on field value xpages - xpages
I am new to xpages and trying to teach myself as I go along. I am trying to learn how to do a computed visible property to hide an object based on the presence of whether a multi valued field contains a string. The classic notes hide when formula would be !#Contains(Display; "SomeValue") How would I do this in xpages SSJS. Thank you very much for any assistance for a new guy.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
pageTitle="Corporate Policy">
<xp:table>
<xp:tr>
<xp:td rendered="false">
</xp:td>
<xp:td>
<xp:inputText value="#{document1.Display}"
id="display">
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
<xp:br></xp:br>
<xp:button value="Close" id="button1"
style="margin-left:5.0px;margin-right:5.0px;margin-bottom:10.0px;margin-top:5.0px">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="true" save="false">
</xp:eventHandler>
</xp:button>
<xp:this.data>
<xp:dominoDocument var="document1" formName="Policy"
action="openDocument">
</xp:dominoDocument>
</xp:this.data>
<xp:this.navigationRules>
<xp:navigationRule outcome="xsp-success"
viewId="/bcbsarequirements.xsp">
</xp:navigationRule>
</xp:this.navigationRules>
<xp:button value="Edit Document" id="button2" style="margin-right:5.0px;margin-bottom:10.0px;margin-top:5.0px"><xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:changeDocumentMode mode="autoEdit" var="document1"></xp:changeDocumentMode>
</xp:this.action></xp:eventHandler></xp:button>
<xp:panel style="height:auto;padding-left:5.0px;padding-right:5.0px;width:auto;padding-top:5.0px">
<xp:panel
style="background-color:rgb(192,192,192);text-align:center;font-weight:bold;font-size:12pt;font-style:italic;width:100%;height:25px;padding-top:3.0px;border-color:rgb(0,0,0);border-style:solid;border-width:medium">
Corporate Policy
</xp:panel>
<xp:panel style="height:auto;border-color:rgb(128,128,128);width:100%;border-style:solid;margin-top:5.0px">
<xp:table style="width:98%">
<xp:tr>
<xp:td
style="border-color:rgb(192,192,192);border-style:dotted;border-width:thin;background-color:rgb(233,233,233);width:121.0px">
<xp:label value="Policy Name:" id="name_Label1"
for="name1" style="width:80.0px;font-weight:bold">
</xp:label>
</xp:td>
<xp:td
style="border-color:rgb(192,192,192);border-style:dotted;border-width:thin;width:210.0px">
<xp:inputText value="#{document1.Name}"
id="name1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Policy Number" id="nbr_Label1"
for="nbr1" style="width:99.0px">
</xp:label>
</td>
<td style="width:234.0px">
<xp:inputText value="#{document1.Nbr}"
id="nbr1">
</xp:inputText>
</td>
</xp:tr>
<xp:tr>
<xp:td
style="background-color:rgb(233,233,233);width:121.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:label value="Effective Date:"
id="effectiveDate_Label1" for="effectiveDate1"
style="font-weight:bold">
</xp:label>
</xp:td>
<xp:td style="width:210.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.EffectiveDate}"
id="effectiveDate1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Policy Owner:"
id="respParty_Label1" for="respParty1">
</xp:label>
</td>
<td style="width:234.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.RespParty}"
id="respParty1">
</xp:inputText>
</td>
</xp:tr>
<xp:tr>
<xp:td
style="background-color:rgb(233,233,233);width:121.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:label value="Revision Date:"
id="revisionDate_Label1" for="revisionDate1"
style="font-weight:bold">
</xp:label>
</xp:td>
<xp:td style="width:210.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.RevisionDate}"
id="revisionDate1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Executive Sponsor"
id="execSp_Label1" for="execSp1">
</xp:label>
</td>
<td style="width:234.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.ExecSp}"
id="execSp1">
</xp:inputText>
</td>
</xp:tr>
<xp:tr>
<xp:td style="width:121.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:label value="Category:" id="category_Label1"
for="category1" style="font-weight:bold">
</xp:label>
</xp:td>
<xp:td style="width:210.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.Category}"
id="category1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Committee Approval Date:"
id="cmApprDate_Label1" for="cmApprDate1">
</xp:label>
</td>
<td style="width:234.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.CmApprDate}"
id="cmApprDate1">
</xp:inputText>
</td>
</xp:tr>
<xp:tr>
<xp:td style="width:121.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:label value="Sub Category:"
id="subCategory_Label1" for="subCategory1" style="font-weight:bold">
</xp:label>
</xp:td>
<xp:td style="width:210.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.SubCategory}"
id="subCategory1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Last Reviewed Date:"
id="lastRevDt_Label1" for="lastRevDt1">
</xp:label>
</td>
<td style="width:234.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.LastRevDt}"
id="lastRevDt1">
</xp:inputText>
</td>
</xp:tr>
<xp:tr>
<xp:td style="width:121.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin;background-color:rgb(233,233,233)">
<xp:label value="Policy Status:"
id="polStatus_Label1" for="polStatus1" style="font-weight:bold">
</xp:label>
</xp:td>
<xp:td style="width:210.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.PolStatus}"
id="polStatus1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Review Frequency:"
id="reviewFreq_Label1" for="reviewFreq1">
</xp:label>
</td>
<td style="width:234.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.ReviewFreq}"
id="reviewFreq1">
</xp:inputText>
</td>
</xp:tr>
<xp:tr>
<xp:td style="width:121.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:label value="Inactive Date:"
id="inactDate_Label1" for="inactDate1" style="font-weight:bold">
</xp:label>
</xp:td>
<xp:td style="width:210.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.InactDate}"
id="inactDate1">
</xp:inputText>
</xp:td>
<xp:td style="width:16.0px"></xp:td>
<td style="width:148.0px;background-color:rgb(233,233,233);border-color:rgb(192,192,192);border-style:dotted;border-width:thin;font-weight:bold">
<xp:label value="Policy Owner E-mail Address:"
id="respEmail_Label1" for="respEmail1">
</xp:label>
</td>
<td style="width:234.0px;border-color:rgb(192,192,192);border-style:dotted;border-width:thin">
<xp:inputText value="#{document1.RespEmail}"
id="respEmail1">
</xp:inputText>
</td>
</xp:tr>
</xp:table>
<xp:br></xp:br>
<xp:table style="width:99.0%;padding-left:5.0px;padding-right:5.0px">
<xp:tr>
<xp:td style="width:718.0px">
<xp:label value="Policy Statement:"
id="polStmt_Label1" for="polStmt1"
style="font-size:10pt;font-weight:bold;color:rgb(0,0,128)">
</xp:label>
</xp:td>
</xp:tr>
<tr>
<xp:td style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin;padding-top:2.0px;padding-bottom:2.0px">
<xp:inputRichText value="#{document1.PolStmt}"
id="polStmt1" style="width:98%;height:auto">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Policy Rationale:"
id="polRat_Label1" for="polRat1"
style="color:rgb(0,0,128);font-weight:bold;font-size:10pt">
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="padding-left:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin;padding-right:15.0px;padding-top:2.0px;padding-bottom:0.0px">
<xp:inputRichText value="#{document1.PolRat}"
id="polRat1" style="width:98.0%">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Policy Scope:"
id="polScope_Label1" for="polScope1"
style="font-size:10pt;color:rgb(0,0,128);font-weight:bold">
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="border-color:rgb(192,192,192);border-style:solid;border-width:thin;padding-left:15.0px;padding-right:15.0px">
<xp:inputRichText value="#{document1.PolScope}"
id="polScope1" style="width:98.0%;height:auto">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Policy Guide:"
id="polGuide_Label1" for="polGuide1"
style="color:rgb(0,0,128);font-size:10pt;font-weight:bold">
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin">
<xp:inputRichText value="#{document1.PolGuide}"
id="polGuide1" style="width:98.0%;height:auto">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Associated Procedures:"
id="polProc_Label1" for="polProc1"
style="color:rgb(0,0,128);font-size:10pt;font-weight:bold">
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin">
<xp:inputRichText value="#{document1.PolProc}"
id="polProc1" style="width:98%;height:auto">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Monitoring:" id="polMon_Label1"
for="polMon1"
style="color:rgb(0,0,128);font-size:10pt;font-weight:bold">
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin">
<xp:inputRichText value="#{document1.PolMon}"
id="polMon1" style="width:98%;height:auto">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Definitions:"
id="polDef_Label1" for="polDef1"
style="color:rgb(0,0,128);font-size:10pt;font-weight:bold">
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin">
<xp:inputRichText value="#{document1.PolDef}"
id="polDef1" style="height:auto;width:98.0%">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label id="polDef_Label2" for="polDef2"
style="color:rgb(0,0,128);font-size:10pt;font-weight:bold">
<xp:this.value><![CDATA[Links & References:]]></xp:this.value>
</xp:label>
</xp:td>
</tr>
<tr>
<xp:td style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin">
<xp:inputRichText value="#{document1.PolDef}"
id="polDef2" style="width:98%;height:auto">
</xp:inputRichText>
</xp:td>
</tr>
<tr>
<xp:td>
<xp:label value="Relevant Governance Standards:"
id="polStds_Label1" for="polStds1"
style="font-size:10pt;color:rgb(0,0,128);font-weight:bold">
<xp:this.rendered><![CDATA[#{javascript:!#Contains(getComponent("display").getValue(), "RGStandards")}]]></xp:this.rendered></xp:label>
</xp:td>
</tr>
<tr>
<xp:td
style="padding-left:15.0px;padding-right:15.0px;border-color:rgb(192,192,192);border-style:solid;border-width:thin">
<xp:inputRichText value="#{document1.PolStds}"
id="polStds1" style="height:auto;width:98%">
</xp:inputRichText>
</xp:td>
</tr>
</xp:table>
</xp:panel>
</xp:panel>
</xp:view>
The values are for example
"Rationale"
"AssocProc"
"Definition"
"Link"
#Contains(getComponent("Display").getValue(), "SomeValue")
Related
Cannot Save xPage
My XPage will not save any data that I enter into it. The screen just flashes and the document that is open just redisplays. I assume it has something to do with where the buttons to save (Speichern) / cancel (Abbrechen) have been placed but, no matter where I place them they don't work. I am having the same problem with the New button - although I assume if the one error is found the other problem will be solved :) Any help would be greatly appreciated as I have been looking into this for the whole day! Here is the code for the page layout control: <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"> <xe:applicationLayout id="applicationLayout1"> <xe:this.facets> <xp:callback facetName="facetLeft" id="facetLeft" xp:key="LeftColumn"> </xp:callback> </xe:this.facets> <xp:callback facetName="facetMiddle" id="facetMiddle"> </xp:callback> <xe:this.configuration> <xe:simpleResponsiveConfiguration navbar="true" invertedNavbar="true" fixedNavbar="fixed-top" navbarText="Thomas Vogel Dokumentation" pageWidth="fluid"> <xe:this.navbarAppLinks> <xe:pageTreeNode label="Neu" page="/xpNewDocument.xsp"></xe:pageTreeNode> <xe:loginTreeNode enabled="true" title="Abmelden" label="Abmelden"></xe:loginTreeNode> </xe:this.navbarAppLinks> </xe:simpleResponsiveConfiguration> </xe:this.configuration> </xe:applicationLayout> </xp:view> Here the code for the menu: <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"> <xe:navigator id="navigator1"> <xe:this.treeNodes> <xe:pageTreeNode label="nach Titel" page="/xpByTitle.xsp"></xe:pageTreeNode> <xe:pageTreeNode label="nach Kategorie" page="/xpByCategory.xsp"></xe:pageTreeNode> <xe:pageTreeNode label="nach Ersteller_in" page="/xpByCreatedBy.xsp"></xe:pageTreeNode> <xe:pageTreeNode label="nach Datum" page="/xpByDate.xsp"></xe:pageTreeNode> </xe:this.treeNodes> </xe:navigator></xp:view> And finally the for the EditDocument page: <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom"> <xp:this.data> <xp:dominoDocument var="document1" formName="fmDoc" action="editDocument"> </xp:dominoDocument> </xp:this.data> <xc:ccPageLayout> <xp:this.facets> <xc:ccMenu xp:key="facetLeft"></xc:ccMenu> <xp:panel xp:key="facetMiddle"> <xp:table> <xp:tr> <xp:td> <xp:label value="Titel" id="titel_Label1" for="titel1"> </xp:label> </xp:td> <xp:td> <xp:inputText value="#{document1.Titel}" id="titel1"> </xp:inputText> </xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label value="Datum" id="dokDatum_Label1" for="dokDatum1"> </xp:label> </xp:td> <xp:td> <xp:inputText value="#{document1.dokDatum}" id="dokDatum1"> <xp:dateTimeHelper id="dateTimeHelper1"> </xp:dateTimeHelper> <xp:this.converter> <xp:convertDateTime type="date" dateStyle="short"> </xp:convertDateTime> </xp:this.converter> </xp:inputText> </xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label value="Kategorie" id="label3" for="kategorie1"> </xp:label> </xp:td> <xp:td> <xp:comboBox id="kategorie1" value="#{document1.kategorie}"> <xp:selectItems> <xp:this.value><![CDATA[#{javascript:var currDB:NotesDatabase = database; var profileDoc:NotesDocument=currDB.getProfileDocument("configDatabase",""); var docUID=profileDoc.getItemValueString("kategorieDok"); var categoryDoc:NotesDocument = currDB.getDocumentByUNID(docUID); var categories = categoryDoc.getItemValueString("kategorie"); #Explode(#Text(categories), ";") }]]></xp:this.value> </xp:selectItems> </xp:comboBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label value="Anhänge" id="label1" for="fileUpload1"> </xp:label> </xp:td> <xp:td> <xp:fileUpload id="fileUpload1" value="#{document1.anhaenge}" useUploadname="true"></xp:fileUpload> </xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label value=" " id="label2" for="fileDownload1"> </xp:label> </xp:td> <xp:td> <xp:fileDownload rows="5" id="fileDownload1" displayLastModified="false" value="#{document1.anhaenge}" hideWhen="true" displayType="false" displayCreated="false" allowDelete="true"> </xp:fileDownload> </xp:td> </xp:tr> <xp:tr> <xp:td colspan="2"> <xp:inputRichText id="inputRichText1" value="#{document1.body}"> </xp:inputRichText> </xp:td> </xp:tr> <xp:tr> <xp:td colspan="2"> </xp:td> </xp:tr> </xp:table> <xp:button value="Speichern" id="button2"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="false"> <xp:this.action> <xp:actionGroup> <xp:saveDocument var="document1"></xp:saveDocument> <xp:openPage name="$$PreviousPage"></xp:openPage> </xp:actionGroup> </xp:this.action> </xp:eventHandler> </xp:button> <xp:button value="Abbrechen" id="button1"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action> <xp:actionGroup> <xp:openPage name="$$PreviousPage"></xp:openPage> </xp:actionGroup> </xp:this.action> </xp:eventHandler> </xp:button> </xp:panel> </xp:this.facets> </xc:ccPageLayout> </xp:view>
In one of the buttons I noticed this part immediate="false" save="false" save should be set to true, I think.
I may have missed it but you should ALWAYS have a displayErrors control. There could be a conversion error or something that you wouldn't otherwise see. You should also think about adding the XPages Log Reader as that can expose other error messages.
Xpages display attachment in dialog box from another document
I am opening a dialog box in an Xpage. In the dialog box I am displaying some fields from 3 other documents, and allowing the user to save some notes. All of this works, except I want to display attachments if there are any. I entered a file download control and for the data source pointed to the target document and did a tmpDoc.getAttachment("attachments") to get the attachments. But nothing shows up. Here is the code from the one row in the table in the dialog box. The other fields work fine, and I know I am getting the tmpDoc, but how do I display the attachment so the user can view it? <xp:td> <xp:fileDownload rows="30" id="fileDownload1" displayLastModified="false"> <xp:this.value><![CDATA[#{javascript: var prtUNID:String = document.getItemValueString("PCTaskParentID"); var tmpView:NotesView = database.getView("(dbAllPCTasksByTaskID)"); var tmpDoc:NotesDocument = tmpView.getDocumentByKey(prtUNID); tmpDoc.getAttachment("attachments") }]]></xp:this.value> </xp:fileDownload> </xp:td> I am having more issues with this. Now it does not really work at all. Here is what I am trying to accomplish. I have a form PC Build. It is all the tasks that must be done to build a PC in my company. There is a list of Master Tasks called PC Tasks. When a new PC Build is saved, the PC Tasks get copied to rspPCTask forms attached to the PC Build. As a user works om building a computer they can open up the PC Build and see the individual tasks. I want them to be able to click on a task and pull up the notes and attachments from the master task, while entering notes for the individual task. Below is a screen shot. In the second field I am grabbing something with javascript. In the first field I am binding the field to the data source, but it is always blank. I cannot figure out why. I have put in all my code below. Any assistance would be greatly appreciated!!! <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex" xmlns:xc="http://www.ibm.com/xsp/custom" dojoForm="true" dojoParseOnLoad="true" dojoTheme="true"> <xp:this.data> <xp:dominoDocument var="document1" action="openDocument" computeWithForm="onsave" formName="PCBuild"> <xp:this.postNewDocument> <xp:actionGroup> <xp:setValue binding="#{document1.ID}" value="#{javascript:session.evaluate('#Unique')}" /> <xp:setValue binding="#{document1.crtDte}" value="#{javascript:session.evaluate('#Today')}" /> <xp:setValue binding="#{document1.crtUsr}" value="#{javascript:session.getCommonUserName()}" /> </xp:actionGroup> </xp:this.postNewDocument> </xp:dominoDocument> </xp:this.data> <xp:this.resources> <xp:styleSheet href="/custom.css" /> <xp:script src="/xpValidationPCBuild.jss" clientSide="false" /> <xp:script src="/xpUtilities.jss" clientSide="false"></xp:script> <xp:styleSheet href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraGrid.css"> </xp:styleSheet> <xp:styleSheet href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraEnhancedGrid.css"> </xp:styleSheet> <xp:dojoModule name="dojox.grid.EnhancedGrid"></xp:dojoModule> </xp:this.resources> <xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.ID = document1.getItemValueString("ID")}]]></xp:this.beforePageLoad> <xp:this.afterPageLoad><![CDATA[#{javascript:viewScope.put("rows","25")}]]></xp:this.afterPageLoad> <xp:panel style="width:900.00px"> <xp:panel> <xp:text escape="true" id="dspDocUNID" style="display:none"> <xp:this.value><![CDATA[#{javascript:if (#IsNewDoc()) { return "0" } else { var doc:NotesDocument = document1.getDocument(); var sUNID = doc.getUniversalID(); return sUNID }}]]></xp:this.value> </xp:text> <xp:scriptBlock id="scriptBlock1"> <xp:this.value><![CDATA[// Conditionally return an image tag to display an icon in a cell function displayIcon (value) { var image = ''; switch (value.toLowerCase()) { case "open": image = '<img alt="" src="blueUncheckedCheckBox15.png" />'; break; case "closed": image = '<img alt="" src="blueCheckedCheckBox15.png" />'; break; default: image = '<img alt="" src="greenChk50.png" />'; break; } return image; }]]></xp:this.value> </xp:scriptBlock> </xp:panel> <xe:widgetContainer id="widgetContainerHeader"> <xp:panel style="padding-top:8.0px;padding-bottom:8.0px"> <xp:button id="button1" value="Edit" style="font-weight:bold;font-size:10pt" rendered="#{javascript:!(document1.isEditable())}"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action> <xp:changeDocumentMode mode="edit" /> </xp:this.action> </xp:eventHandler> </xp:button> <xp:button value="Save" id="button3" style="font-weight:bold;font-size:10pt" rendered="#{javascript:(document1.isEditable())}"> <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="plContainer"> <xp:this.action> <xp:actionGroup condition="#{javascript:validateForm()}"> <xp:saveDocument var="document1"></xp:saveDocument> <xp:executeScript> <xp:this.script><![CDATA[#{javascript://Get handle on current doc and see if it is a new doc var thisDoc:NotesDocument = document1.getDocument(); var tg = thisDoc.getItemValueString("tasksGenerated"); if (tg != "Y") { //Set flag to Y and save document thisDoc.replaceItemValue("tasksGenerated","Y") thisDoc.save(true) var rspDoc:NotesDocument; //Loop through all PC Task Docs var pcTasksView:NotesView = database.getView("(dbAllPCTasks)"); var pcTaskDoc:NotesDocument = pcTasksView.getFirstDocument(); var tmpDoc:NotesDocument; while (pcTaskDoc != null) { //Make new doc and add as response to this doc rspDoc = database.createDocument(); rspDoc.replaceItemValue("Form","rspPCTask"); rspDoc.replaceItemValue("category",pcTaskDoc.getItemValueString("category")); rspDoc.replaceItemValue("title",pcTaskDoc.getItemValueString("title")); rspDoc.replaceItemValue("status","Open"); rspDoc.replaceItemValue("PCBuildParentID",thisDoc.getItemValueString("ID")); rspDoc.replaceItemValue("PCTaskParentID",pcTaskDoc.getItemValueString("ID")); rspDoc.replaceItemValue("PCTaskParentUNID",pcTaskDoc.getUniversalID()); rspDoc.replaceItemValue("order",pcTaskDoc.getItemValueInteger("order")); rspDoc.save(); tmpDoc = pcTasksView.getNextDocument(pcTaskDoc); pcTaskDoc.recycle(); pcTaskDoc = tmpDoc; } }}]]></xp:this.script> </xp:executeScript> <xp:openPage name="$$PreviousPage"></xp:openPage> </xp:actionGroup> </xp:this.action> </xp:eventHandler> </xp:button> <xp:button id="button2" style="font-weight:bold;font-size:10pt" value="Close"> <xp:eventHandler event="onclick" submit="true" refreshMode="norefresh"> <xp:this.action> <xp:openPage name="$$PreviousPage" target="openDocument" /> </xp:this.action> </xp:eventHandler> </xp:button> <xp:text escape="true" id="computedField3" style="font-size:14pt;color:rgb(79,79,79);padding-left:px;padding-bottom:px;margin-bottom:px;padding-right:25.0px"> <xp:this.value><![CDATA[#{javascript:document1.getItemValueString("crtDte")}]]></xp:this.value> </xp:text> </xp:panel> </xe:widgetContainer> <xp:panel id="plContainer"> <xp:panel> <xe:widgetContainer id="widgetContainerData"> <xe:formTable id="frLocationMaster" disableErrorSummary="true" disableRowError="true"> <xp:this.facets> </xp:this.facets> <xe:formRow id="formRow5" labelPosition="none" style="padding-bottom:10.0px"> <xp:table style="width:99%" border="0" cellpadding="0" role="presentation" cellspacing="0" id="table4"> <xp:tr> <xp:td style="width:80.0px;min-width:120px"> <xp:text id="cfTitle" xp:key="header" style="font-size:14pt;color:rgb(79,79,79);padding-left:px;padding-bottom:px;margin-bottom:px"> <xp:this.value><![CDATA[#{javascript:"PC Build"}]]></xp:this.value> </xp:text> </xp:td> <xp:td style="width:250.0px"> </xp:td> <xp:td style="text-align:right"> <xp:text escape="true" id="computedField1" style="font-size:14pt;color:rgb(79,79,79);padding-left:25.0px;padding-bottom:px;margin-bottom:px"> <xp:this.value><![CDATA[#{javascript:document1.getItemValueString("crtUsr") + " on "}]]></xp:this.value> <xp:this.rendered><![CDATA[#{javascript:if (#IsNewDoc() == 1) { return false } else { return true; }}]]></xp:this.rendered> </xp:text> <xp:text escape="true" id="computedField2" style="font-size:14pt;color:rgb(79,79,79);padding-left:px;padding-bottom:px;margin-bottom:px;padding-right:px" value="#{document1.CrtDte}"> <xp:this.converter> <xp:convertDateTime type="both" timeStyle="short" /> </xp:this.converter> <xp:this.rendered><![CDATA[#{javascript:if (#IsNewDoc() == 1) { return false } else { return true; }}]]></xp:this.rendered> </xp:text> </xp:td> </xp:tr> </xp:table> </xe:formRow> <xe:formRow id="formRow1" labelPosition="none"> <xp:table style="width:99%" border="0" cellpadding="0" role="presentation" cellspacing="0" id="table3"> <xp:tr> <xp:td style="width:10%;min-width:120px;"> <xp:label id="label4" for="formRow1" value="Employee Name" /> </xp:td> <xp:td style="width:100px"> <xp:inputText value="#{document1.employeeName}" id="employeeName1"> <xp:typeAhead mode="full" minChars="1" valueListSeparator="," ignoreCase="true" id="typeAhead1"> <xp:this.valueList><![CDATA[#{javascript:var dbname = new Array(#Subset(#DbName(), 1),"names.nsf"); return #DbColumn(dbname,"($PeopleByName)",1);}]]></xp:this.valueList> </xp:typeAhead> </xp:inputText> </xp:td> <xp:td style="width:20px"> <xe:valuePicker id="valuePicker1" for="employeeName1" pickerIcon="/picker.png" dialogTitle="Choose Employee"> <xe:this.dataProvider> <xe:simpleValuePicker> <xe:this.valueList><![CDATA[#{javascript:var db:NotesDatabase = session.getDatabase(database.getServer(),"names.nsf"); var viewHandle:NotesView = db.getView("($PeopleByName)"); return viewHandle.getColumnValues(0) }]]></xe:this.valueList> </xe:simpleValuePicker> </xe:this.dataProvider> </xe:valuePicker> </xp:td> <xp:td> <xp:message id="message1" for="employeeName1" /> </xp:td> </xp:tr> </xp:table> </xe:formRow> <xe:formRow id="formRow2" labelPosition="none"> <xp:table style="width:99%" border="0" cellpadding="0" role="presentation" cellspacing="0" id="table1"> <xp:tr> <xp:td style="width:10%;min-width:120px;"> <xp:label id="label1" for="formRow1" value="Computer Name" /> </xp:td> <xp:td style="width:100px"> <xp:inputText value="#{document1.computerName}" id="computerName1"> </xp:inputText> </xp:td> <xp:td style="width:20px"> </xp:td> <xp:td> <xp:message id="message2" for="computerName1" /> </xp:td> </xp:tr> </xp:table> </xe:formRow> <xe:formRow id="formRow3" labelPosition="none" rendered="false"> </xe:formRow> <xe:formRow id="formRow4" labelPosition="none" rendered="false"> </xe:formRow> </xe:formTable> </xe:widgetContainer> </xp:panel> </xp:panel> <xp:panel> <xe:widgetContainer id="widgetContainer1"> <xp:panel> <xp:viewPanel rows="30" id="viewPanel1" var="thisEntry"> <xp:this.facets> <xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="headerPager" id="pager1"> </xp:pager> </xp:this.facets> <xp:this.data> <xp:dominoView var="view1" viewName="(dbAllRpPCTasks)"> <xp:this.keys><![CDATA[#{javascript:document1.getItemValueString("ID")}]]></xp:this.keys> </xp:dominoView> </xp:this.data> <xp:viewColumn columnName="title" id="viewColumn5" displayAs="link"> <xp:viewColumnHeader value="Title" id="viewColumnHeader5"> </xp:viewColumnHeader> <xp:eventHandler event="onclick" submit="false" refreshMode="partial" refreshId="panelDig"> <xp:this.action><![CDATA[#{javascript:viewScope.UNID = thisEntry.getDocument().getUniversalID(); viewScope.parUNID = thisEntry.getDocument().getItemValueString("PCTaskParentUNID"); getComponent('dialog1').show()}]]></xp:this.action> </xp:eventHandler> </xp:viewColumn> </xp:viewPanel> <xp:panel id="panelDig"> <xp:this.data> <xp:dominoDocument var="document2" formName="PCTask" action="editDocument" documentId="#{javascript:viewScope.parUNID}"> </xp:dominoDocument> <xp:dominoDocument var="document3" formName="rspPCTask" action="editDocument" documentId="#{javascript:viewScope.parUNID}"> </xp:dominoDocument> </xp:this.data> <xe:dialog id="dialog1" style="width:700px;height:600px" refreshOnShow="true"> <xp:table> <xp:tr> <xp:td> <xp:label value="Master Title" id="label2" /> </xp:td> <xp:td> <xp:text escape="true" id="computedField4" value="#{document2.title}"> </xp:text> </xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label value="Master Task Notes" id="label3" /> </xp:td> <xp:td> <xp:text escape="true" id="computedField5"> <xp:this.value><![CDATA[#{javascript:var tmpDoc:NotesDocument = database.getDocumentByUNID(viewScope.parUNID) tmpDoc.getItemValueString("notes")}]]></xp:this.value> </xp:text> </xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label value="Master Attachments" id="label5" /> </xp:td> <xp:td></xp:td> </xp:tr> <xp:tr> <xp:td></xp:td> <xp:td></xp:td> </xp:tr> <xp:tr> <xp:td> <xp:label id="label7" value="Notes" /> </xp:td> <xp:td> <xp:inputTextarea id="inputTextarea1" style="width:98.0%;height:100px" value="#{document3.notes}"> </xp:inputTextarea> </xp:td> </xp:tr> </xp:table> </xe:dialog> </xp:panel> </xp:panel> </xe:widgetContainer> </xp:panel> </xp:panel> <xp:eventHandler event="onClientLoad" submit="true" refreshMode="norefresh"> <xp:this.script><![CDATA[try { dojo.byId("#{id:employeeName1}").focus(); } catch (e) { }]]></xp:this.script> </xp:eventHandler> </xp:view>
To show all rich text field's attachments of "another" document in a fileDowndload control: add a panel around your fileDownload control, add a dominoDocument data source to the panel set attribute documentId to "another" document's UNID set fileDownload's value to document's rich text field (in your case the rich text field is called "attachments") <xp:td> <xp:panel> <xp:this.data> <xp:dominoDocument var="documentPCTaskParent" action="openDocument"> <xp:this.documentId><![CDATA[#{javascript: document.getItemValueString("PCTaskParentID") }]]></xp:this.documentId> </xp:dominoDocument> </xp:this.data> <xp:fileDownload rows="30" id="fileDownload1" displayLastModified="false" value="#{documentPCTaskParent.attachments}"> </xp:fileDownload> </xp:panel> </xp:td> BTW tmpDoc.getAttachment("attachments") you used doesn't return all attachments of rich text field "attachments" but would look for an attachment with the file name "attachments" somewhere in document.
I would avoid the file download control if possible. What you likely want to do is just build html links or images to the actual files themselves. So it's mostly a matter of figuring out the correct URL to get to it. Typically these are old school "non XPages" URL's... the classic domino stuff. Everything I know about doing this I learned form this post: http://www.wissel.net/blog/d6plinks/SHWL-86QKNM
Short answer: you can add tmpDoc as a true document data source (using
Xpages: make tables with all fixed cells but last
I am having trouble understanding why I cannot control tables in Xpages in general and in HTML in particular. I want some cells to have a fixed-width. For example, my first column in the table I am working on is a checkbox, so there is zero reason the width should ever change. The second column has two images that can be different but the width is always going to be the same. I HATE it when the size of these columns moves all around, as it looks bad. Ideally I would like to be able to specify which cells are fixed and which are resizable, but if I cannot do that I want a table with every cell fixed except the last one. Any suggestion on how to do this would be greatly appreciated. David is correct, I should have added code. I am doing so now. The code below is a repeat that generally dos what I want it to do. I am very happy for any suggestions to improve it or make it more flexible. <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"> <xp:this.data> <xp:dominoView var="view1" viewName="(xpAllPCBuilds)" /> </xp:this.data> <xp:this.resources> <xp:styleSheet href="/custom.css" /> </xp:this.resources> <xe:firebugLite id="firebugLite1" /> <xe:widgetContainer id="widgetContainerView" style="width:99.00%"> <xp:panel> <xp:repeat id="repeat1" var="rowData" indexVar="repeatIndex" value="#{view1}"> <xp:this.facets> <xp:text disableTheme="true" xp:key="header" escape="false"> <xp:this.value><![CDATA[<table class='lotusTable repeatRowColors' border='0' cellspacing='0' cellpadding='0'> <tr class ='lotusFirst lotusSort scope='col'> <th>Employee Name</th> <th>Computer</th> <th>Create Date</th> <th>Create User</th> <th>ID</th> </tr> </thead>]]> </xp:this.value> </xp:text> <xp:text disableTheme="true" xp:key="footer" escape="false"> <xp:this.value> <![CDATA[</table>]]></xp:this.value> </xp:text> </xp:this.facets> <xp:this.rows><![CDATA[#{javascript:var rows:Integere = viewScope.get("rows"); if (rows == null) {return 5} else {return rows}}]]></xp:this.rows> <xp:tr id="rowDataContainer"> <xp:td style="width:200px;min-width:200px;max-width: 200pxx"> <xp:link escape="true" id="link1" value=""> <xp:this.text><![CDATA[#{javascript:rowData.getColumnValue("employeeName")}]]></xp:this.text> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action> <xp:openPage name="xpFormPCBuild.xsp" target="openDocument"> <xp:this.documentId><![CDATA[#{javascript:rowData.getDocument().getUniversalID()}]]></xp:this.documentId> </xp:openPage> </xp:this.action> </xp:eventHandler> </xp:link> </xp:td> <xp:td style="width:50px;min-width:50px;max-width: 50px"> <xp:text escape="true" id="computedField2"> <xp:this.value><![CDATA[#{javascript:rowData.getColumnValue("computerName");}]]> </xp:this.value> </xp:text> </xp:td> <xp:td style="width:75px;min-width:75px;max-width: 75px"> <xp:text escape="true" id="computedField3"> <xp:this.value><![CDATA[#{javascript:rowData.getColumnValue("CrtDte");}]]> </xp:this.value> </xp:text> </xp:td> <xp:td style="width:200px;min-width:200px;max-width: 200px"> <xp:text escape="true" id="computedField4"> <xp:this.value><![CDATA[#{javascript:rowData.getColumnValue("crtUsr");}]]> </xp:this.value> </xp:text> </xp:td> <xp:td> <xp:text escape="true" id="computedField5"> <xp:this.value><![CDATA[#{javascript:rowData.getColumnValue("ID")}]]></xp:this.value> </xp:text> </xp:td> </xp:tr> </xp:repeat> </xp:panel> </xe:widgetContainer> </xp:view>
If you are using xp:table you can insert some HTML inside the xp:table container: a colgroup (http://www.w3schools.com/tags/tag_colgroup.asp). With that you can control your column widhts with CSS e.g. style="width:200px"
Data in custom control not being maintained when user navigates around the application
My application uses the Application Control. In the right column of the control itself I put another CC that displays information about the user. The idea is that as the user moves throughout the app they will always see this info. The data is displayed on the first view, but not in any of the forms. The data appears in views, but not in the forms, even though I am able to retrieve the document unid in one field. The code for the Custom Control is below. Any help would be greatly appreciated. <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"> <xp:this.data> <xp:dominoDocument var="document1" action="openDocument" databaseName="TheTruth.nsf" formName="employee"> <xp:this.documentId><![CDATA[#{javascript:var userName:NotesName = session.createName(session.getEffectiveUserName()); var db:NotesDatabase = session.getDatabase(database.getServer(), "DATABASE.nsf"); var viewHandle = db.getView("(ViewName)"); var doc:NotesDocument = viewHandle.getDocumentByKey(userName.toString()); return doc.getUniversalID();}]]></xp:this.documentId> </xp:dominoDocument> </xp:this.data> <xp:panel id="pnlHeader" style="width:275.00px;padding-right:30.0px"> <xe:widgetContainer id="widgetContainerHeader"> <xp:panel style="padding-top:8.0px;padding-bottom:8.0px"> <xp:table> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox1" style="width:97.0%;font-weight:bold;font-size:18pt" value="#{document1.HR_FullName}"> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox2" style="width:97.0%" value="#{document1.HR_MarketSegmentText}"> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox3" style="width:97.0%"> <xe:this.value><![CDATA[#{javascript:"Blank"}]]></xe:this.value> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox4" style="width:97.0%"> <xe:this.value><![CDATA[#{javascript:var userName:NotesName = session.createName(session.getEffectiveUserName()); var db:NotesDatabase = session.getDatabase(database.getServer(), "DATABASE.nsf"); var viewHandle = db.getView("ViewName"); var doc:NotesDocument = viewHandle.getDocumentByKey(userName.toString()); return doc.getUniversalID();}]]></xe:this.value> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox5" style="width:97.0%"> <xe:this.value><![CDATA[#{javascript:"Blank"}]]></xe:this.value> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox6" style="width:97.0%"> <xe:this.value><![CDATA[#{javascript:"Blank"}]]></xe:this.value> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox7" style="width:97.0%"> <xe:this.value><![CDATA[#{javascript:"Blank"}]]></xe:this.value> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox8" style="width:97.0%" value="#{document1.HR_OfficePhone}"> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox9" style="width:97.0%" value="#{document1.HR_CellPhone}"> </xe:djTextBox> </xp:td> </xp:tr> <xp:tr> <xp:td> <xe:djTextBox id="djTextBox10" style="width:97.0%" value="#{document1.HR_DirectDial}"> </xe:djTextBox> </xp:td> </xp:tr> </xp:table> </xp:panel> </xe:widgetContainer> </xp:panel> </xp:view>
Your need to set ignoreRequestParams="true". Because that's not set, on XPages that do not have a document passed in the URL, it's showing the document you define. On pages where you open, edit or create a document, the documentId etc are getting overridden by what's in the URL parameters, which explains why you're not seeing the document you expect. ignoreRequestParams on the datasource in your custom control will solve your problem.
Xpages Binding to edit control in a repeat
I'm a problem understanding how to do dynamic binding to a edit control. The backend from has fields fItem01 fItem02... fPD01 fPD02.. fRQR01 fRQR02.. I can get the values for all the fields but having been able to defined the binding for edit control. I've read all the posting on this subject but haven't figure out what I'm doing wrong. Also tried using a custom control with a property for the binding but that didn't work either. Thanks for any help on this Bob <xp:this.data> <xp:dominoView var="view1" viewName="vwMultItem"></xp:dominoView> </xp:this.data> <xp:table border="1"> <xp:tr> <xp:td> <xp:label value="Title" id="label1"></xp:label> </xp:td> <!--<xp:td></xp:td>--> </xp:tr> <xp:repeat id="repeat1" rows="1" value="#{view1}" var="row"> <xp:panel id="panelDocData"> <xp:this.data> <xp:dominoDocument var="document1" formName="frMultItem" action="editDocument" documentId="#{javascript:row.getNoteID();}"> </xp:dominoDocument> </xp:this.data> <xp:repeat id="repeat2" rows="3" var="rowItem" first="0" indexVar="indexVar"> <xp:this.value><![CDATA[#{javascript:new Array("01", "02", "03")}]]></xp:this.value> <xp:tr> <xp:repeat id="repeat3" first="0" rows="2" var="rowName"> <xp:this.value><![CDATA[#{javascript:new Array("fItem","fPD")}]]></xp:this.value> <xp:td> <xp:text escape="true" id="computedField1"> <xp:this.value><![CDATA[#{javascript:document1.getItemValueString(rowName+rowItem); }]]></xp:this.value> </xp:text> </xp:td> </xp:repeat> <xp:td> <xp:inputText id="inputText1" value="#{javascript:'#{document1.fRQR'+'01'+'}'}"> </xp:inputText></xp:td> </xp:tr> </xp:repeat> </xp:panel> </xp:repeat> </xp:table>
As you know which fields you want to put into the repeat control you can calculate the fieldNames in inner repeat block completely with javascript:["fItem"+rowItem,"fPD"+rowItem,"fRQR"+rowItem] and then use them in edit control's value EL #{document1[fieldName]}. <xp:repeat id="repeat2" var="rowItem" indexVar="indexVar"> <xp:this.value><![CDATA[#{javascript:["01", "02", "03"]}]]></xp:this.value> <xp:tr> <xp:repeat id="repeat3" var="fieldName"> <xp:this.value><![CDATA[#{javascript:["fItem"+rowItem,"fPD"+rowItem,"fRQR"+rowItem]}]]></xp:this.value> <xp:td> <xp:inputText id="inputText2" value="#{document1[fieldName]}"> </xp:inputText> </xp:td> </xp:repeat> </xp:tr> </xp:repeat>