Page 1 of 1

Content control "Click here to enter text" placeholder

PostPosted: Wed Aug 25, 2010 6:33 am
by dawns
I am programmatically inserting custom XML to be displayed in a docx file. I am making use of the bindingrole=repeat, and everything is working wonderfully! However, if I have a content control setup for an attribute which isn't always set in the XML, say a person's title. Then when I open the processed docx file, I see the text "Click here to enter text." where the title would normally be. How can avoid that, and have the content control just display nothing?

When I created the content control in Word, I overwrote that default "Click here to enter text" with "title" (which also matches the tag name, etc)

Thanks, Dawn

Re: How to avoid "Click here to enter text."

PostPosted: Wed Aug 25, 2010 11:14 pm
by jason
dawns wrote:When I created the content control in Word, I overwrote that default "Click here to enter text" with "title" (which also matches the tag name, etc)


If you did that, I'm not sure how "Click here to enter text" could come back? I tried creating an example to see whether I could replicate, but to no avail. Perhaps you could post your example (zipped up)?

In my testing, when the XPath expression pointed to an attribute which was missing entirely, docx4j inserted an empty paragraph (replacing whatever was there ie whether it was "Click here to enter text" or "title").

Word leaves the existing content, so this is probably what docx4j should do as well. But then you'd have to do some work yourself to remove placeholder text if that's what you wanted.

Perhaps we could have a flag which determines what docx4j should do. What do you think?

------------
Did you see the link to the docx4j user survey? Please take the survey, if you haven't already done so. Thanks!

Re: Content control binding: "Click here to enter text."

PostPosted: Thu Aug 26, 2010 1:35 am
by dawns
I would have expected that if an XPath doesn't contain a value, that nothing would display for that content control. Instead, I'm seeing "Click here to enter text.".

I've attached the source docx and the _processed docx (I've stripped sensitive details from the doc)

I could see how others may want to set a default value (meaning set a default value in the source docx file) that would be displayed if the XPath value is not specified, but I don't have a need for that.

Re: Content control binding: "Click here to enter text."

PostPosted: Tue Aug 31, 2010 12:02 am
by jason
Hi,

Looking at these documents, it is Word 2007 which puts "Click here to enter text" when something is bound to an empty element (eg <title/>).

If the element has a character (eg a space) in it, Word will render that character. Maybe there is a non-printable character you could put into your <title>?

For docx4j to defeat this Word behaviour, docx4j would need to do that, or remove the w:dataBinding from the relevant content control.

empty content control after processing

PostPosted: Fri Sep 10, 2010 2:28 pm
by bzha005
Hi Jason,

I think this might be a bug in docx4j. if a content control is bound to an empty xml element, after processing I expected not able to see the content control, but I can see it have text "click here to enter text". in the attached zip file I got a template.docx on which you can not see address 5 and address 6, after I injected the injected-data.xml I got after-processed.docx on which you can see content controls for address 5 and address 6 have text "click here to enter text".
Is there anyway to get rid of the text "click here to enter text"?

Re: empty content control after processing

PostPosted: Fri Sep 10, 2010 5:02 pm
by jason
Now merged with viewtopic.php?f=6&t=395

What do you think?

Re: empty content control after processing

PostPosted: Mon Sep 13, 2010 10:40 am
by bzha005
Hi Jason,

Thanks for your reply, I would think having a flog to determine what docx4j should do is a more flexible solution. The possible options are: leave as default, insert blank, remove the content control etc.

Re: Content control binding: "Click here to enter text."

PostPosted: Tue Sep 14, 2010 6:10 pm
by jason
Turns out this behaviour is because of the presence of w:sdtPr/w:placeholder.

See http://www.documentinteropinitiative.or ... ddf7a.aspx

I've modified things so that applyBindings will always remove the w:placeholder element from the document: see http://dev.plutext.org/trac/docx4j/changeset/1226

Another approach which may have had the same effect would be to redefine to blank the placeholder text specified in the document part of type bbPlcHdr.

If removing w:placeholder is an insufficient solution for anyone, please speak up!

Re: Content control "Click here to enter text" placeholder

PostPosted: Thu Jan 13, 2011 7:55 am
by punchysandoval
Apologies if the answer to this question is simple, but how would I go about adding the Placeholder Text back, and customizing it?
What I'm trying to accomplish is setting up a Word template with bound content controls, but without any "data" in them--upon launch of the document, I'd like the controls to appear with custom placeholder text rather than being blank or having any default data. Word's Placeholder Text acts differently than when data is present--with Placeholder Text (or when blank), the user only has to click once in the content control to enter their data (if there is placeholder text, it deletes with a single click). But if there is any data in the control, the user must double-click to select it and then delete it. Am I missing some obvious way to accomplish this? Many thanks for any assistance.

Re: Content control "Click here to enter text" placeholder

PostPosted: Thu Jan 13, 2011 9:51 am
by punchysandoval
Ugh, apologies for the noise. After more struggle and experimentation, I answered my own question.
In case others face the same issue, here is what worked for me:
1. Create a content control in the Word document.
2. Edit Properties of the content control. (Assign it a Title, etc.)
3. Enter Design Mode.
4. Click in the content control and replace Word's default placeholder text with the desired custom placeholder text for that content control. In my case, where the Title of the content control is "Name," the custom placeholder text is "Name."
4. Exit Design mode.
5. Copy the content control (click on it once, then click on the Title tab so the whole control turns dark blue, then Ctrl+C) and paste it to wherever else in the document the data from that control needs to be repeated.
6. Close the document.
7. Open the document in the Word Content Control Toolkit.
8. Create new Custom XML Part
9. In Edit View, enter "non-databound" content controls, e.g.:
<root>
<firstName/>
<lastName/>
</root>
10. In Bind View, map the Custom XML nodes to the corresponding content controls.
11. Save
12. Open Word document. The content controls all have "custom" placeholder text instead of "default data"--click once in the control and the placeholder text disappears.

At least, it seems to have worked. Fingers crossed.