Opening different xpages forms from a view panel - xpages

I have an Xpages application that pulls data from another .nsf file. I have a view panel linked to a view in that db. The view has documents with several different forms in it. I want to be able to open each document in it's own form(xpage).
How do I write a computed At Runtime, open selected document using: statement that will select the correct Xpage to present the document.

If you use the Data View component instead of a View Panel, you can compute the pageName attribute, referencing the var attribute to return a different value for each row based on the document that row represents. The flexibility of the Data View component also makes it easier to make your app look more like a modern web application and less like an Excel spreadsheet. As an additional bonus, the mobile theme invokes a renderer that makes each Data View instance look like a native mobile list, so using Data Views instead of View Panels simplifies mobile development.

You have 2 options:
use "use xpage associated with form" and edit the form's property
use a SSJS formula to compute the Form. You provide a variable name in the view control var to access a view row as XSPViewEntry. If the Form is in a view column even one you don't display you use .getColumnValue otherwise getDocument.getItemValueString
Does that work for you?

Maybe this mothed can help you: Unable to get document page name for
Hope this helps
Mark

I had a similar problem today. I use only one form but 3 different xpages for associated with this form. I have 3 different document types in the view. I used rowData the get the type of the document.
try{
var v=rowData.getColumnValue("form");
if(v.indexOf("x")> -1){var page ="x.xsp"}
else if(v.indexOf("y") > -1){var page = "y.xsp"}
else{var page = "z.xsp"}
}catch(e){
var page = "x.xsp"
}
So to your view you can create a column with the value of the form and you can use it.

I have used the extension library Dynamic View control which has an event you can code to get a handle to the NotesViewEntry which was selected. See the demo database page Domino_DynamicView.xsp and the Custom Event Handler tab for an example.
Note, in 8.5.3 (I have not upgraded yet) if you add or edit the eventHandler for onColumnClick it will be added to the XPages source as an xe:eventHandler. It needs to be an xp:eventHandler to work. The way to do it is to copy the code in the source from the exiting event and delete it. Recreate the event and update the code. Then go back into the source and change the tags within the eventHandler to xp:.

Related

Command Not Handled Exception

I'm new to Domino Designer. I'm trying to modify an existing application which is running on a remote server. I create a blank xPage and view in browser and it works. I add a label and view in browser and it works. I add a combo box and setup a data source for my xPage. The data source is in the current application and I'm using a view. I setup my combo to point to that data source and specify BindTo value. I view it in browser and I get Error 500 "HTTP Web Server: Command Not Handled Exception" I can open the view that I've used and see all the data in the view. I can even add, edit, and delete from the view.
Ideas... Thnxs in advance.
Additional Info. I've added a "View" from "Container Controls" and used the same data source and the same view and it also works in the browser.
The error being printed is:
javax.faces.el.PropertyNotFoundException: Error getting property 'CompanyName' from bean of type lotus.domino.local.View
com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:119)
com.ibm.xsp.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:144)
com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:182)
com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:163)
com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.j‌​ava:257)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:150) ....
This was already answered in the comments, but I want to write a better answer.
The problem in this case is that a view data source is being used for editing a document. Directly, this is not a possibility, though there are a few great ways to get around this. The first way, and my favorite, is to use an inline form. I think the Extension Library Demo database offers a few great examples of how to go about doing this. One way is to use a tooltip dialog. Another way is an inline form. A repeater is used and for every row in the view, a hidden panel can be made which contains the document data source and all field which are required to be changeable. By clicking on a button or link, the panel is made visible. This is my favorite variant because it is simple, quick, and generally looks great.
Another way to go about this is to have a view data source only, but use scripts to retrieve the document and set the values in the background and then save and release. It all depends on what you are trying to achieve.
My main recommendation is to look at the ExtLib demo and take a look at what they are doing there.

xpages embedded view or view panel

I know it is a very simple question , but I'm trying to see the difference between a view panel ( that I drag from the Container Controls ) and an embedded view.
How can I add an embedded view on my xpages?
Or the 2 items are one and the same.
The reason why I'm asking this question: I have a view panel on my xpage ( I thought it is like an embedded view in clasic lotus notes programming ) where I have listing some docs. The first column is categorized based on the UNID document.
I noticed if I compose again another document, this view contains all the previous docs., and all the UNID categorized. The view panel isn't empty.
In lotus notes programming:
If I have a main form and a computed text field with #Text(#DocumentUniqueId) and some button for composing another form ( of course, when clicking the button I saved the main form to obtain the UNID ), and this form has the same text field name as the previous - I'm passing the UNID to this second form. If the main form contains an embedded view listing all documents saved from the second form I will use the first column categorized and hidden with the name of the field from the second form ( which will contain the UNID ). If I save and close the 1st main, and then I'll compose another main form, the embedded view is not listing the previous documents already saved.
Well, this view is already created.
I did drag and drop this view in myxpage. I have a button inside myxpage that shows a dialog. Here a datasource is declared, the dialog containing some fields. In the main xpage ( where is defined another datasource ) there is a computed field which takes the UNID of the document. Before I click the dialog I save the first datasource, to pass the value UNID to other field inside the dialog.
I save the datasource from the dialog & close the dialog, and then the view panel ( which is the view from the lotus notes classic presented above ) lists the doc. If I close the main xpage ( save it if is a new one ) and then open another main document, the view isn't empty, it contains the previous document lists. ( I tried also to hide it, if the xspDoc is new. But when I try adding other docs. from the dialog, the view panel lists also the previous documents from the previous doc., even if the UNIDs are distinct )
Thanks in advance.
To explain this best, it's good to consider what a view and an embedded view in Notes Client is. A view determines the look and feel, like a View Panel and by default will show all documents found by the selection criteria. So in this case the documents available correspond to a dominoView datasource bound to the underlying view with no additional criteria defined.
An embedded view still uses the view to determine the look and feel, but will not display the first column (that's effectively a property of the embedded view "control" in Notes Client). In the View Panel you choose which columns display, so you would need to code that yourself on the View Panel, where you choose which columns to display. The embedded view also has a property to define the single category. But the View Panel and other repeating containers (like Data Table and repeat control) don't restrict the data available, that's done by the datasource - a dominoView or e.g. a ViewEntryCollection for anything other than the View Panel. So in that you set the filter.
However, a new document does not have a UNID, so it cannot restrict what is displayed. Instead, I think a good approach is to set the visibility so the View Panel is only displayed if it's not a new document. You can use loaded, if you fully reload the page after save, or else rendered.
First off, this is not a stupid question.
I am assuming you are using a self implemented parent response system and have a view sorted by the parent UNID. Under the data source of the view panel, find the the "filter by category name" option. there compute the UNID value, or category value you are searching for.
Steps:
insure that the background view is categorized (ascending order is best to insure that this works, though I doubt it is needed)
drag (my favourite is the dynamicViewPanel) a view control onto the xpage.
Under Properties/Data there is a place to calculate the value of the category to show. If you want an exact match, check the exact match check box.
If you mistype the category value or the value is not there, then no documents will be shown.
if you put in an empty value all documents are shown (at least in the tests that I can remember)
if documents are returned, the categorized column is automatically hidden.
EDIT
If you are reading the value from a field, you can use the code:
xspDoc.getItemValueString("fld");
If you are searching based on the UNID, again, hide the viewPanel if the document is new. If the value is not yet set, also hide the panel.
If you have two custom controls, even if a custom control is embedded in the second, you cannot easily have one custom control access the values of the datasource in another. I am sure there are ways to trick this into working, but in this case, use a viewScope variable to access the values and possibly an onLoad, onChange or onSave event to update the viewScope variable. Make sure to verify that the result is not null or empty by either printing it out to the server log or another field.
Final Edit after question edit/expansion
These are the steps that I would take to do what you described.
You have your parent document XPage. Insert all fields for this Xpage.
Drag a dynamicViewPanel onto the XPage. If parentDoc is New, then hide.(this could be a custom control in theory, but if you are having trouble, try it without for the sake of trouble shooting.
Set dynamicViewPanel datasource to ignoreReqeustParams.
Calculate the datasource and setting the "Filter by category name" filter. When computing this, for the sake of ease and troubleshooting, print this value out to the server, or other logging mechanism. You can delete it later.
Verify that the correct UNID/Value is being inserted into the document you create in the dialog.
If you are using a scoped variable to hold the filter value, be sure you are using viewScope and not appliationScope or sessionScope.
if you are using a custom control and standard parameters (not scopedVars), verify that the compositeData variable is being updated with a log or server print.
Consider setting Dialog Properties/AllProperties/basics/refreshOnShow to true
Play with the partial refresh option for the dialogOpen action, test a full vs partial refresh.
Remember to set the ignoreRequestParams for the document you are creating in the dialog to true
Consider making the new document data source created in the Dialog to request scope.
And of course consider and test all datasources being defined on the XPage on not some here, some there.
Verify that you are taking the value of the UNID from the main document and not the new dialog document by mistake!
Those are all of the tips I can think of right now, pretty much in the order I'd try them in. If that does not help, then I suspect there is a piece of this puzzle that you are not including in the question. Remember, try to keep things as simple as you can. You can over think things, make things harder than they need be.

Can you compute which custom control to use?

Think "computed subform", but in Xpages.
On one of my custom controls, depending on a certain value, I want to either present a custom control that renders a drop-down list using a combobox or renders an input box with a type-ahead.
This is on a custom control that renders a view, with all view configuration choices handled by a document rather than design, so several different views utilize the same custom control.
For example: I have a By Status view using the custom control that has status as the first column and we use a combobox to allow the user to select which Status value to filter by. Another view is sorted by Requisition number and I want to use a type-ahead instead of the combobox.
My preference is to use the same dynamic view custom control for both and have a formula that determines which of the two (comboBox or inputText) to use. How do I compute which custom control to load?
(Credit for the dynamic view control goes to Scott Good's folks over at Teamworks Solutions.)
During it's life cycle, an XPage exists in two places. First of all a representation of the XPage's relevant components is stored on the server. Then the page goes through a lifecycle, retrieving properties from documents, checking which components should be rendered, retrieving the data for any repeating control such as a View Panel etc., and passing the relevant HTML to the browser. The browser is the second place it exists.
So you can't compute a custom control as such. All you can do is set the loaded property, and loaded needs to be based on a non-dynamic calculation such as a viewScope variable, the current XPage name, a view name stored on the XPage etc. What you would have difficulty doing would be using a different custom control based on data on that row entry.
The other option is the Dynamic Content control or Switch control from the Extension Library. Both are similar to using the loaded property, in that you're putting both custom controls on the page and choosing which to display.
From what you're describing, the loaded property should cover what you need.
Some time back I saw this question on StackOverflow where the author had used Include Page control (xp:include) to include custom controls using pageName attribute based on formula.
<xp:include>
<xp:this.pageName><![CDATA[${javascript:sessionScope.ccPageName + ".xsp";}]]> </xp:this.pageName>
</xp:include>
Similar to the technique described by Paul Withers in his answer the attribute of pageName is also computed on page load.

Making the webform submission results as a link in Drupal 6?

I am a newbie in using Drupal 6 and I am still walking in the dark in terms of module familiarization and module configurations. Lately, I installed the Webform module for my site to be able to let users submit a request. In my Webform, there is a Select View field where it lists all contents of a specific Content Type on my Drupal site. I was able to use a View as a datasource for my normal webform select component via the Webform View Reference Component that's whay I have a custom <select> field which are views on my Webform. Now, after a successful submission of the form, I go to Results and found the data which are saved upon submission. What I want is that, on my Results page, the selected option from the list, which basically are views, will be a link to their respective views. This is how it looks like,
I am really lost right here. Can someone lend me a hand on how to make this possible? Cheers.
Install this module http://drupal.org/project/webform_report it will be displayed in table format and also you can customize the report & also It will create separate content type.
Below is the screen shot for webform report, you can also view, edit & delete from report itself.

Conditional Client Side Validation?

I have a radio button group that gets it's values using an #Dblookup. In addition to the name to appear in the radio button group, the document also has a field to determine if another field on the xPage should be displayed or not.
If the field is displayed then it should be required.
I can do the conditional validation just fine in SSJS using an #DbLookup to lookup the document selected in the radio button group.
But I would like to be able to do it CS so it is faster and so it looks like my other validations. Is there anyway to do this?
If a field is not rendered then the node will not exist in the DOM. Your CS javascript would need to examine the DOM and look for the node, normally by looking for a specific ID. As Xpages changes the ID's sent to the browser your validation function would either need to be computed so it would know what ID to look for or you would need to look for it in some other unique way ( like add a css class name to just that field and then do a DOM search for nodes with that class name )
Once you can determine if the field has been rendered then you can run your usual CS validation routine against the other field.
If you're using client-side validation throughout your app, setting the required property on the field should achieve what you need.
If not, it may be worth looking at the Extension Library Dojo Validation Text Box. All the Extension Library Dojo control run client-side validation, even if validation is set as server-side at application level. Bear in mind that for the Dojo Validation Text Box, just setting the required property is not enough. You need to add more specific validation.
After that, the key is to ensure the partial refresh event on your radio group is set to skip validation. I haven't tried, but I believe that should achieve what you need.

Resources