Is there a way how to adjust HTML generated by xPage from document rich text field? - xpages

Is there a way how to adjust HTML generated by xPage from document rich text field? I have q document from which the rich text field content is displayed on xPage using computed text control. Solution works nice except, that xPages engine generates strange HTML from the rich text field. When displaying page on web using standard form, all texts written by default font and default size doesn't contain markup arround so on could use CSS to style it. Not this way in xPages. Everything have tag around and its not funny seeing generated font tag around the div tag :-(
<div class="tcl-columns3-in">
<font size="2" face="sans-serif"></font>
<font size="2" face="sans-serif">
<b>Header text ...</b>
</font>
<font size="2" face="sans-serif">
<div class="tcl-box-outlined">
text ...<br>
</div>
</font>
</div>
Is there a way how to get rid of out of generated HTML?. I looked to html filtering option with ASF filter but it requires to adjust settings on filesystem, which not option for me ...

There are a number of steps you narrow down your problem. RichText -> MIME -> RichText is not a problem free relationship. As Carl pointed out, you can have a look at the raw RichText -> Mime conversion result. Does that look OK? Then you could use a Dijit ContentPane to pull that content in.
It also depends on what control you use to display the content. You might have different success with textbox and RichText editor. If you look for very high fidelity you either store your RT as mime (a property of a RT field) or use Coex Edit a commercial server plug-in

use a computedField in your Xapge, and set the value to something like this
var rt = document1.getDocument().getFirstItem("Body");
return rt.getUnformattedText()
using this technique you can also format the content the way you like as it is all text. I use this to display colored and formatted json and xml

Related

Docusign API - Setting margins for HTML documents

I'm working on integrating a PHP app with the DocuSign REST API. I'm creating new documents from HTML, similar to document 1 in the example here. The structure comes through just fine, but the margins on the resulting document are way too wide for my purposes, and I can't find a way to set them to a custom value. It seems to ignore the margins on my HTML body and just set it to a default of 1 inch.
Normally if you create a document using a pdf for example, the custom margins on the pdf would be used, so it seems like there should be some way to do this for HTML. Am I missing something?
I would try a negative value for the outermost div's margin value. Eg
<div style="margin:-2em;">
<p>Blah blah blah</p>
</div>

notes style field in xpages

Is there any possibility to make an editbox in xpages that looks like an editable field - notes style from Lotus Notes? Or to be able to display the field value in more lines, if it necessary ?
I tried adding Auto for the editbox, but it no works.
rows and cols properties allow you to change the size. You can also use Dojo Simple Text Area or Dojo Text Area controls from Ext Lib. The latter auto-expands depending on the content, so rows and cols are not applicable (see the part in XPages Extension Library book on that).
If you're talking about the field handles round the top left and bottom right of a field, I don't think web development supports partial borders. It will be a generic CSS web development solution you require, rather than anything specific to XPages.
I know this is kind of late but here's what I came up with:
https://codepen.io/gcoxdev/pen/MmdrYz
<div class="notes-field">
<div class="notes-editable contenteditable="true"></div>
<textarea name="test"></textarea>
</div>
Of course, you'll have to convert that to xpages markup.
Essentially I'm creating a content-editable div with unicode characters for the handles then updating the underlying textarea with javascript.
You can read my article about it here:
http://gcoxdev.com/xpages-notes-style-field
Hope that helps!

Dynamic database search result on a website

This question regards website programming. My primary languages are c++/c# and I don't know much about web development, except that say I understand html and css. That's why I'm looking for a relatively simple solution, preferably something out of the box. I don't have any experience with JavaScript, but for the sake of this project I'm willing to learn it if necessary.
Let's say I have a database, where each entry is about a book. It contains the fields: title, author(s) and publication date.
I would like to create a simple website with a search box that has this dynamic result feature, so that you get suggestions after you type in a few letters. All those suggestions, as well as search results, need to be based purely on the database.
This could be a static website or based on any Content Management System, I'm familiar with Joomla, but was unable to find an out-of-the box component that would do just that. All those search modules search the entire website and I only need to search the database.
Probably I can help you with how to implement this feature. We used to call this feature as autocomplete menu.
First you decide minimum characters to populate autocomplete menu. For example 2
By using javascript you write keyup event. Once the characters count reaches to the minimum character count. You send AJAX request to the server.
The server should process this request and do the database search and form a json or xml response or plain text to the client.
The client parses that response into javascript object and construct a dynamic html for autocomplete menu with the data and render it into the DOM hence display's just below the search text box.
Now if you want to display the first result inside the textbox as you type. Here is the method I can suggest as similar as google search box
Place one label or span just below the input text box. By using css make its position exactly match with the position of the text box. Make sure the starting of text of both input text and label matches. Make the text color of the label less brighter than the font color of text. The font size and font family of the label should match the input text field's style. Now by using Javascript display the first or most matched text inside the label. Please find the sample code below
<!DOCTYPE html>
<head>
<style>
label {
position:relative;
}
body, input {
font-family: 'verdana';
font-size: 12px;
}
</style>
</head>
<html>
<body>
<form action="demo_form.asp">
<input type="text" name="fname" placeholder="Matched Text" /><br>
<label> Matched Text</label><br>
</form>
</body>
</html>

How to display HTML inside h:inputTextarea

How to display value with HTML tag inside h:inputTextarea?
In DB I have column contain data, it contain plain text and HTML tag, I want display it on h:inputTextarea. How can I do it?
i want display HTML inside h:inputTextArea it mean in DB contain <br/> or <b> and </b> , when it display on h:inputTextArea it must display bold or break line.
That's not possible due to the nature of HTML <textarea> element. Even, if it was possible this puts doors wide open to XSS injection attacks. Also, how would you ever let the enduser edit the markup in the textarea like changing bold to for example italics or to add another markup? That's plain impossible with a <textarea>.
If your sole intent is to have a rich text editor, then you need to homegrow one with help of a <div> and a good shot of JavaScript or, better, use an existing JSF component which achieves this. For example, PrimeFaces' <p:editor>.
Or, if your sole intent is to display it only, then use <h:outputText> with the escape attribute set to false. Once again, keep XSS risks in mind.
Use the f:verbatim tag -> JSF Verbatim Tag

Is it possible to format a NumberField in a page layout?

I'm developing a SharePoint publishing site and setting up its content types and page layouts. I need to display the value for a Year field with type Number. The markup currently is:
<SharePointWebControls:NumberField FieldName="Year" runat="server" id="Year" />
The problem with the default behaviour is that it shows each number with a comma, e.g. "2,009" instead of "2009". Is there a way I can set some sort of String.Format syntax on the field to make it display correctly?
I tried creating a new rendering template which looks like this:
<SharePoint:RenderingTemplate ID="YearNumberField" runat="server">
<Template>
<SharePoint:FormField ID="TextField" runat="server"/>
</Template>
</SharePoint:RenderingTemplate>
... but there doesn't appear to be any 'Format' property on the FormField object.
Thanks for any help.
Update:
I tried wrapping the SharePoint:FormField tag inside SharePoint:FormattedString. Unfortunately the field was not formatted, same results as this question.
The issue is that the rendering template must use FormField. This always renders the value in the format: 1,989 . To resolve this the rendered text needs to be trapped and altered to get the desired output. Here are two approaches to resolving this:
1. Write a custom control inherited from NumberField
The RenderFieldForDisplay and RenderFieldForInput methods can be overridden to provide the desired output. Additional properties can be added to the control to describe additional behaviour.
Pros: No changes to rendering templates required.
2. Write a custom control for use in the rendering template
A control that (for example) uses regular expressions to alter text can wrap around the FormField control.
<SharePoint:RenderingTemplate ID="YearField" runat="server">
<Template>
<RX:RegexManipulatorControl runat="server"
Mode="Replace"
Expression=","
Replacement="">
<SharePoint:FormField runat="server"/>
</RX:RegexManipulatorControl>
</Template>
</SharePoint:RenderingTemplate>
Pros: Generic solution can be used for any type of field.
from Just Another SharePoint Blog
Open the list view in SharePoint
Designer.
Right click on the data view web part.
(the list)
Select Convert to XSLT Data View
Click on the number field you would
like to format
A > will appear showing Data Field,
Format As
Click on the link below Format As -
Number formatting options
Under Options deselect Use 1000
separator
Click OK
Save your changes and hit F12 to
preview

Resources