以就地形式进行文件上传控制

时间:2015-03-06 01:12:08

标签: xpages

我试图在xpages中以inplace形式添加文件上传控件。保存表单时,会创建一个文档,但不保存在就地表单中选择的附件。

有人可以告诉我是否有办法吗?

以下是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 个答案:

答案 0 :(得分:0)

确保将“文件上载”控件绑定到富文本字段。例如,对于具有名为rtf_field的富文本字段的数据document1,请使用#{document1.rtf_field}

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

答案 1 :(得分:0)

这里有一些工作代码,请确保您有一个名为&#34; Main&#34;和一个名为Body的Richtext字段,格式为

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