0
votes

I an trying to add file upload control in the inplace form in xpages. When I save the form, a document is created but the attachment selected in the inplace form is not saved.

Can someone tell me if there is any way to do this?

Here is the sample code from Extionsion Library Demo.

<?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">

<xc:OneUILayout id="cc4cconeuilayout"  navigationPath="/Core/InPlaceForm">
    <xp:this.facets>
        <xp:panel xp:key="LeftColumn" id="panel4">
            <xc:LeftCore id="cc4ccLeftCore" ></xc:LeftCore>
        </xp:panel>
    </xp:this.facets>
    <xp:panel>
        <xp:panel>
            <xp:this.data>
                <xp:dominoView var="view1" viewName="AllContacts"></xp:dominoView>
            </xp:this.data>
            <xp:label
                value="This shows the in place editing capability" id="label5"
                style="font-weight:bold">
            </xp:label>
            <xp:br></xp:br>
            <xp:br></xp:br>
            <xp:pager layout="Previous Group Next" id="pager1"
                xp:key="header" for="repeat1" partialRefresh="true">
            </xp:pager>
            <xp:repeat id="repeat1" rows="15" value="#{view1}"
                var="row">
                <xp:div id="rowDataContainer">
                    User: &#160;
                    <xp:text escape="true" id="computedField1"
                        value="#{row.FirstName}">
                    </xp:text>
                    ,&#160;
                    <xp:text escape="true" id="computedField2"
                        value="#{row.LastName}">
                    </xp:text>
                    &#160;
                    <xp:span id="inform">
                        <xp:link escape="true" id="link1">
                            <xp:this.text><![CDATA[#{javascript:var c = getComponent("inPlaceForm1")
if(c.isVisible()) {
return "Close";
} else {
return "Edit"
}}]]></xp:this.text>
                            <xp:eventHandler event="onclick"
                                submit="true" refreshMode="partial" refreshId="inform">
                                <xp:this.action><![CDATA[#{javascript:var c = getComponent("inPlaceForm1")
c.toggle()
}]]></xp:this.action>
                            </xp:eventHandler>
                        </xp:link>
                        <xp:br></xp:br>
                        <xe:inPlaceForm id="inPlaceForm1"
                            partialEvents="true">
                            <xe:this.afterContentLoad><![CDATA[#{javascript:print("InPlaceForm: After Content Load")}]]></xe:this.afterContentLoad>
                            <xe:this.beforeContentLoad><![CDATA[#{javascript:print("InPlaceForm: Before Content Load")}]]></xe:this.beforeContentLoad>
                            <xp:panel>
                                <xp:this.data>
                                    <xp:dominoDocument
                                        var="document1" formName="Contact" action="editDocument"
                                        documentId="#{javascript:row.getNoteID()}"
                                        ignoreRequestParams="true">
                                    </xp:dominoDocument>
                                </xp:this.data>

                                <xp:table role="presentation">
                                    <xp:tr>
                                        <xp:td>
                                            <xp:label
                                                value="First name:" id="firstName_Label1"
                                                for="firstName1">
                                            </xp:label>
                                        </xp:td>
                                        <xp:td>
                                            <xp:inputText
                                                value="#{document1.FirstName}" id="firstName1"
                                                required="true">
                                            </xp:inputText>
                                        </xp:td>
                                        <xp:td>
                                            Required field, client
                                            side&#160;validation
                                        </xp:td>
                                    </xp:tr>
                                    <xp:tr>
                                        <xp:td>
                                            <xp:label
                                                value="Last name:" id="lastName_Label1" for="lastName1">
                                            </xp:label>
                                        </xp:td>
                                        <xp:td>
                                            <xp:inputText
                                                value="#{document1.LastName}" id="lastName1"
                                                required="true" disableClientSideValidation="true">
                                            </xp:inputText>
                                        </xp:td>
                                        <xp:td>
                                            Required field, server
                                            side validation
                                        </xp:td>
                                    </xp:tr>
                                    <xp:tr>
                                        <xp:td>
                                            <xp:label
                                                value="E mail:" id="eMail_Label1" for="eMail1">
                                            </xp:label>
                                        </xp:td>
                                        <xp:td>
                                            <xp:inputText
                                                value="#{document1.EMail}" id="eMail1">
                                            </xp:inputText>
                                        </xp:td>
                                        <xp:td></xp:td>
                                    </xp:tr>

                                <xp:tr><xp:td>Attachment</xp:td><xp:td>
<xp:fileUpload id="fileUpload1" value="#{document1.attachments}"></xp:fileUpload></xp:td><xp:td></xp:td></xp:tr></xp:table>
                                <xp:button value="Ok"
                                    id="button2">
                                    <xp:eventHandler event="onclick"
                                        submit="true" refreshMode="partial" refreshId="repeat1" immediate="false" save="true">
                                        <xp:this.action>
                                            <xp:actionGroup>
                                                <xp:saveDocument></xp:saveDocument>
                                                <xp:executeScript>
                                                    <xp:this.script><![CDATA[#{javascript:var c = getComponent("inPlaceForm1")
c.hide()}]]></xp:this.script>
                                                </xp:executeScript>
                                            </xp:actionGroup>
                                        </xp:this.action>
                                    </xp:eventHandler>
                                </xp:button>
                                <xp:button value="Label"
                                    id="button1">
                                <xp:eventHandler event="onclick"
                                    submit="true" refreshMode="partial" refreshId="repeat1">
                                    <xp:this.action><![CDATA[#{javascript:document1.save();
var c = getComponent("inPlaceForm1")
c.hide()}]]></xp:this.action>
                                </xp:eventHandler></xp:button></xp:panel>
                        </xe:inPlaceForm>
                    </xp:span>
                </xp:div>
            </xp:repeat>
        </xp:panel>
    </xp:panel>
</xc:OneUILayout>
</xp:view>
2
Always add code and accept matching answersstwissel

2 Answers

0
votes

Make sure you bind the File Upload control to a rich text field. For example, for data document1 with rich text field named rtf_field use #{document1.rtf_field}

<xp:fileUpload id="fileUpload" value="#{document1.rtf_field}">
  <xp:eventHandler event="onchange" submit="true" refreshMode="complete">
  </xp:eventHandler>
</xp:fileUpload>
0
votes

Here you have some working code, make sure you have a form called "Main" and a Richtext field called Body in the form

<?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:inPlaceForm id="inPlaceForm1"></xe:inPlaceForm>
    <xp:panel>
        <xp:this.data>
            <xp:dominoDocument var="d" formName="Main"></xp:dominoDocument>
        </xp:this.data>
        <xp:fileUpload id="fileUpload1" value="#{d.Body}"></xp:fileUpload>
        <xp:button value="Save" id="button1">
            <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
                <xp:this.action><![CDATA[#{javascript:d.save()}]]></xp:this.action>
            </xp:eventHandler>
        </xp:button>
    </xp:panel>
</xp:view>