1

Using 8.5.3 UP1 with the Hotfix for the multi-rich text control issue.

I am dynamically binding rich text controls that are within a custom control wrapped in a repeat control. The rich text controls render just fine, except that the image upload functionality does not work. If I click on the image upload, choose a file, and then click send to server, the image apparently never makes it there.

Here is my code:

The Repeat Control:

<xp:repeat id="rptSections" rows="99" repeatControls="false"
    var="sections" indexVar="rptIndex" value="#{javascript:2}">
    <xc:ccDynamicSections_2 rptIndex="#{javascript:rptIndex}">
        <xc:this.fieldName><![CDATA[#{javascript:"contentRT"+rptIndex}]]></xc:this.fieldName>
    </xc:ccDynamicSections_2>       
</xp:repeat>

The custom control:

<xp:inputRichText id="inputRichText1" value="#{document1[compositeData.fieldName]}" >   
</xp:inputRichText>

I'm pretty sure if I can find a way to bind the rich text controls at run time I can make this work. I tried to do this and it appears to work on the page but when I go to save the document I get a error such like "Could not save the document NEW_79 NotesException: Object has been removed or recycled"

Bind after page load attempt:

<xp:repeat id="rptSections" rows="99" repeatControls="false"
    var="sections" indexVar="rptIndex" value="#{javascript:2}">

    <xp:text escape="true" id="computedField1">
        <xp:this.value><![CDATA[#{javascript:var application = facesContext.getApplication();var scopedField = 'content'+rptIndex;var valueBinding = application.createValueBinding( '#{document1.' + scopedField + '}');getComponent("inputRichText1").setValueBinding('value', valueBinding );"test"+rptIndex}]]></xp:this.value>
    </xp:text>

    <xp:inputRichText id="inputRichText1"></xp:inputRichText>
</xp:repeat>

Any help is appreciated.

Dan Herman
  • 1,395
  • 1
  • 15
  • 26
  • For dynamic binding, I have just answered this question: http://stackoverflow.com/questions/9913331/dynamic-data-binding/9915444#9915444 – Serdar Basegmez Mar 30 '12 at 19:16
  • I've left the office but I'll give this a try first thing Monday. Thanks for the help. – Dan Herman Mar 30 '12 at 20:16
  • I tried using a $ instead of # before the javascript and it doesn't work with that. I get an error -it can't reference rptIndex. I've updated my code to show my last attempt.Here is the code I tried with the $: ` <![CDATA[${javascript:var application = facesContext.getApplication(); var scopedField = 'content'+rptIndex; var valueBinding = application.createValueBinding( '#{document1.' + scopedField + '}'); getComponent("inputRichText1").setValueBinding('value', valueBinding ); "test"+rptIndex}]]> ` – Dan Herman Apr 02 '12 at 11:10

1 Answers1

2

I think you should set repeatControls to true. Or else it will fail to correctly bind to your datasource. See this page too.

Ferry Kranenburg
  • 2,625
  • 1
  • 17
  • 23
  • 1
    Thanks!! That did it! Oddly when I first tried it, it didn't appear to work and then later it did? Anyway, thanks for the help. – Dan Herman Apr 03 '12 at 14:05
  • Code: ` <![CDATA[#{javascript:var application = facesContext.getApplication(); var scopedField = 'content'+rptIndex; var valueBinding = application.createValueBinding( '#{document1.' + scopedField + '}'); getComponent("inputRichText1").setValueBinding('value', valueBinding ); "test"+rptIndex}]]> ` – Dan Herman Apr 03 '12 at 14:05