I know this is probably easy, but I can't figure it out.
Have an Xpage with 6 fields or so, bound to underlying form. User will enter some data. The possible values for one field, location, are in a view in a different db. I want the user to be able to type in the first few characters and be able to select the value.
I think this should be easy, and I am just missing something. Any help would be greatly appreciated.
Use typeAhead. Here's an example (assuming the lookup field is in column 1 of the view called viewName) where type ahead starts after 2 characters:
<xp:inputText id="test" value="#{document.test}">
<xp:typeAhead mode="partial" minChars="2" ignoreCase="true" id="typeAhead1">
<xp:this.valueList><![CDATA[#{javascript:return #DbColumn(database.getServer() + "!!" + "path/db.nsf", "viewName", 1);}]]></xp:this.valueList>
</xp:typeAhead>
</xp:inputText>
In the properties of the edit box there's type ahead. Enter #DbColumn(....); that should do the trick. Example here: http://www-10.lotus.com/ldd/ddwiki.nsf/m_Home.xsp?documentId=D74C33EADB3DC730852575F600668099#mobileViewer
Related
I am developing an ADF based project. The code below is a part of my View. I want to show a NUMBER value in the input text field which can be changed anyway. All I want is that value to be right aligned in the field. I have read that contentStyle="text-align:right; does the job, but the requirement is not to use it. I am wondering myself if the value is of type number and convertNumber is used in the code, should the value be right aligned automatically?
I will appreciate any help you give me!
<af:inputText value="#{row.bindings.B.inputValue}"
styleClass="class" simple="true"
required="#{bindings.A.hints.B.mandatory}"
maximumLength="#{bindings.A.hints.B.precision}"
shortDesc="#{bindings.A.hints.B.tooltip}"
id="bb" autoSubmit="true"
disabled="#{viewScope.aBean.getSmth('abc')}"
valueChangeListener="#{viewScope.aBean.onBChange}">
<f:validator binding="#{row.bindings.B.validator}"/>
<af:convertNumber groupingUsed="false"
pattern="#{bindings.AA.hints.B.format}"/>
Use AFFieldNumberMarker in styleClass property of af:inputText, It will right align your value
I have two forms Job and Comment,type of these forms are document and response.
There is a field in the Job form that save name of developer and there is a field in the Comment form
that I want to get the name of developer from Job when I want to create a comment for selected job.
One way to get field values from a parent document (in your case from the Job document) is to use a data context to create a parentDoc object. You can then refer to this parentDoc object to get field values from the parent document.
Start by creating a parentDoc data context:
<xp:this.dataContexts>
<xp:dataContext var="parentDoc">
<xp:this.value><![CDATA[#{javascript:
return database.getDocumentByUNID(currentDocument.getParentId());
}]]></xp:this.value>
</xp:dataContext>
</xp:this.dataContexts>
If you just want to display a value from the parent document (and not save it in the response document), you can then use a computed field to display the value from the parent document (using expression language to refer to the field from the parentDoc object):
<xp:text escape="true" id="displayParentField" value="#{parentDoc.field}" />
You can also use the value from the parent document as the default value for an input field:
<xp:inputText id="responseValue" value="#{currentDocument.responseField}" defaultValue="#{parentDoc.field}" />
Short answer, you filter the 2nd data source with the value of the field. It could be the response field on the response doc or the value of the field that exists on both docs.
Long answer, This is a common xPages question, one I have asked myself. Take a look at this question. xPage with multiple datasources has the second datasource always opened in edit mode
A simple solution, I added the below code in default value of Assign field in response form it works now
var parentDoc = database.getDocumentByID(document1.getParentId())
return parentDoc.getItemValueString("Developer")
Thank you Per Henrik Lausten your answer helped me to solve this issue.
How do you disable the CkEditor for Rich Text fields so you only render a basic <texarea> tag with no editor whatsoever?
I'm sure I must be missing something obvious but I don't see to be able to create a document using an XPage with a field stored as RT without using the CkEditor. I want to be able to prompt the user to enter 'a lot' of text but only via a simple multiline input and have that stored as RT.
If I have a..
form with a RT field
an XPage with a xp:inputTextarea control bound to said field
a save button
a documentdatasource linked to that form
on save the document is created with the field value but it's stored as text rather than RT. Adding in computeWithForm to the dds properties doesn't help.
Is the only way to have some kind of querysave or custom converter to manually turn it into RT?
If I use the xp:inputRichText control it saves fine as RT but I don't want the CkEditor in the UI, just a basic . Is there a someway to do a editor=plain to the xp:inputRichText control?
I've been looking at trying to override the dojoType or renderType with no luck
Thanks!
You can use <xp:customConverter> in <xp:inputTextarea> to convert the text to rich text item.
For getAsObject you would write this code (document1 is your data source):
var rtitem:NotesRichTextItem = document1.getDocument().createRichTextItem("rtfield");
rtitem.appendText(value);
return null; // Return null as field has already been created
And for getAsString you would simply fetch the contents of rich text field and textual value.
value.getContentAsText()
The variable value is a standard variable which contains the actual value of the field. So you code for <xp:inputTextarea> would look something like this:
<xp:inputTextarea id="inputTextarea1" value="#{document1.rtfield}">
<xp:this.converter>
<xp:customConverter getAsString="#{javascript:value.getContentAsText()}">
<xp:this.getAsObject><![CDATA[#{javascript:var rtitem:NotesRichTextItem = document1.getDocument().createRichTextItem("rtfield");
rtitem.appendText(value);
return null;}]]></xp:this.getAsObject>
</xp:customConverter>
</xp:this.converter>
</xp:inputTextarea>
NOTE: If you wish to update the rich text field using the text area then you need to write additional code in getAsObject
I am not sure how to manipulate the field type. I assume that Domino know what is going on with the control in much the same way that the custom controls are formatted to match the content type. You might be able to force the content type.
I can present this as an alternative. You can do a custom toolbar in the ckeditor to remove the toolbar and make it appear like a normal text field. There may be UI complications with doing so though. You would also have a status bar to contend with to make it appear as a plain white box. There should be another dojo attribute type for this.
This code will give you a rich text box with no toolbar
<xp:inputRichText id="inputRichText1"
value="#{document1.content}">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="toolbar">
<xp:this.value><![CDATA[#{javascript:var myToolbar = "[['']]";
return myToolbar}]]>
</xp:this.value>
</xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:inputRichText>
I want to add a field to an existing xPage, and need to run past a few xPage fundamentals to check their validity.
I have done the following:
In order to ensure that my dev and prod sites work, the form the document is bound to is calculated (as the datasource resides in a diff db).
My new field is called 'NewField', and I have used simple data binding, chosen document1 (same as the rest of the fields on my document), and entered the new field name (can't select from the drop down as the document is calculated).
I have also created the field on the actual notes document, however I did not think I HAD to do this? Also, it's on a calculated subform so not sure if this is relevant? This is an xpage version of an existing notes form - both client and web access are applicable for the application.
I thought it would create the field specified in 'Bind To' if it was missing, however even with it on the notes form, it still does not store the value.
Whats gone wrong:
The field is created on the document, however the value is not being populated. The value stored against the notes document is an empty string.
There is nothing complicated here, not doing anything funky, yet the value is not mapped?
The rest of the fields (created when I created the initial document) are mapped correctly.
Any suggestions? Is this a rookie error with adding fields to an existing xPage?
A
As requested, here is the code for both the data binding and a field that does work, and one that does not.
Here is my initial code to define document1. It does call an agent post save, however this agent does nothing with the field value that is not being assigned.
<xp:this.data>
<xp:dominoDocument var="document1" action="openDocument">
<xp:this.databaseName><![CDATA[#{javascript:var sname = ("","test\\testdb.nsf");
return sname;}]]>
</xp:this.databaseName>
<xp:this.formName><![CDATA[#{javascript:return "MainForm"}]]>
</xp:this.formName>
<xp:this.postSaveDocument>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var sname = #Name([CN]",#Subset(#DbName(),1));
var dbname = "test/testdb.nsf";
var dbTest:NotesDatabase = session.getDatabase(sname, dbname);
if (dbTest.isOpen()){
ag = dbTest.getAgent("UpdateDoc");
noteid = document1.getDocument().getNoteID();
ag.run(noteid);
} }]]></xp:this.script>
</xp:executeScript>
</xp:this.postSaveDocument></xp:dominoDocument>
</xp:this.data>
And then here is the code for the field assignment that is not working.
<xp:inputText value="#{document1.NewField}"
id="inputText25" disableClientSideValidation="true" styleClass="entryboxes">
</xp:inputText>
And then here is the code for a field assignment that is working.
<xp:inputText value="#{document1.CLRef}"
id="inputText4" rendered="#{javascript:#IsNewDoc()}" styleClass="entryboxes">
</xp:inputText>
I thought that this was fairly standard.
update 8/10
So - I have worked out that this happens only when I have conditionally hidden cell. This has a basic formula, asking the row to be visible based on the value of another field. The display / no display functionality is working (see below for code), yet, for a reason unknown to me, it does not save the value.
var hw = getComponent("module");
var hwv = hw2.getSubmittedValue();
hwv == "Product1" || hwv == "Product2" || hw2v == "Product3"
If I create any other field NOT hidden (and make up the field name), it maps to the document correctly (as I thought it should). The good news is I have managed to replicate with a new form, so it appears to be with me wanting to hide a row conditionally, and not an issue with my form? Any ideas?
OK - I continued to have issues with the field mapping when the cell was hidden in certain conditions. So, I ended up making the cell visible, and then having the field mandatory only in certain circumstances. So, question not answers, but a work around used.
I have a combo box with descriptions that are long in length. I'm trying to find the best way to show the full description. One thing I came across was the title attribute which causes a popup to show on hover. I tried to use the "attrs" property in XPages to add a title property, but xp:selectItem and xp:selectItems "attrs" do not appear in the HTML output.
Anyone have any ideas or a different method to try? Thanks for any thoughts.
EDIT: I ended up changing the combo box into a dialog pick list. This satisfied my requirements.
Did you consider using xe:djComboBox from Extension Library?
See http://www-10.lotus.com/ldd/ddwiki.nsf/dx/djComboBox_Dojo_Combo_Box_ddxl853
<xe:djComboBox id="djComboBox1" value="#{sessionScope.djComboBox1}"
tooltipPosition="auto">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="autoComplete" value="false">
</xp:dojoAttribute>
<xp:dojoAttribute name="labelType" value="html">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
<xp:selectItems>
<xp:this.value>
<![CDATA[#{javascript:return new Array("<b>Apples</b>|apples", "Oranges|oranges")}]]>
</xp:this.value>
</xp:selectItems>
</xe:djComboBox>
Each element in array should have following format "label|value|description|disabled", where only label is mandatory. See: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.ui.doc%2Fwpd_controls_cref_selectitems.html
If the description of your items is so long that they dont fit in a combobox you could either:
Change the length of the combobox using css.
Retrieve the description and only display a portion of it (lets say first 100 chars ).
Descriptions in comboboxes should be 'descriptive' ( hence the word description ). I would go for the second approach and add something in front of the description so the description is still usefull for the users.
For instance when have a list of projects. These titles are 100+ characters long. Instead of displaying the full description. Cut them of and use the project code as a prefix so that it will display
ProjectCode - {first 100 chars of description}.
This way users still know what they select because of the project code.