This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 20, 2013, 2:17 PM
10 Posts

Design Method for XPages App

  • Category: Other
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: XPages Application
  • Replies: 9

I have a project that requires the ability to read and write information to a traditional Notes Application (call it LN1) from an Xpages Application (call it XP1).  The information that will be written to LN1 needs to be also stored as in the XP1 Application.

 

The information that is stored in the Notes Db is a series of fields i.e. qty01, qty02…, Part01, Part02…, and so on for other fields for up to 15 rows.  The data is stored in a main document (parent) for the first 15 rows and sequential rows are stored in a series of response (child) documents. 

 

The XP1 Application needs to read the information from main and all the response documents presenting them in a table with an input number field to enter a received quantity.  The received quantity needs to be added back to the LN1 application summing it with the existing value.  The XP1 need to store the Qty##, Part# and received quantity to new a document in the XP1 application.

 

I have tried this using several different methods utilizing nested Repeat controls but have ran into a road blocks with the approaches I have used. 

 

Does anyone have any thoughts on a good method to this design?

Thanks

Bob

Aug 20, 2013, 5:49 PM
453 Posts
I assume that you are trying to run an XPages and traditional N/D app in the same database

First of all the back end data is the same whether access from a Notes Client or an XPages client. Though in a project that I am working on to convert a traditional Notes application to an XPages application I found that the traditional data structure was limited. I have a context similar to your part01, part02 etc. and this can work in both environments, however, I found it far more flexible to spin each of the line items off into their own document then use a repeat control to display them. But you can pass a multi-value field to a repeat control as well.

I started out to make it so a traditional Notes Client and an XPages Client would co-exist in the same Application but ended up abandoning that approach. I have written some agents to go through the database and convert the existing documents to the format that I intend to use for the XPages design.

Not sure that helps, but the back-end documents are essentially the same regardless of the client used to access them.

 

Aug 20, 2013, 6:53 PM
10 Posts
Separate Databases

Thanks Bill

I had planned from the beginning  to have it in separate databases.  I can get the data from all the documents and fields using nested repeat control and build inputText tags to get the received quantity.  The problem I'm having is trying to process that information back to the original documents and then create a new document with the information about the  received quantities.

I'm either having problem getting the data from client side javascript to the server side to save it. Or I'm getting and exception error when running any server javascript from the view datasource used in the repeat rowData.

I thinking the exception is because the rowData has expired.  error CLFAD0134E: Exception processing XPage request.

I'm looking for different methods to either acquire the data without nested repeats or processing the information.  One thought was to use scoped variables to store an array for the parts and received quantities but  I found the scope variables are not storing data as array.  Or maybe I just not doing scoped variable correctly for an array.

Bob

Aug 20, 2013, 8:46 PM
586 Posts
hmmm

Bob,

It would be interesting to know a couple things first..  like what kinds of tools do you have...  are you working in Java?  or is it mostly SSJS?  

So this is a little weird... at least to me...  you're doing a line item thing...  but the first 15 items you're going to store on the document itself?  and several multi-value fields?  and anything above 15 items is going to be seperate documents?  You're mixing 2 strategies?

Bill has a good point about the data...  I would assume you're only using 1 database as well.  And yes...  having to support the notes client app is really going to limit your data possibilites for this application.

I be interested in hear more detail on your roadblocks..

hmmm if you were in the Java world...  I don't think it would be that difficult to translate...  an object for the mainDoc... objects for the items...  so you read in the mainDoc...  crate itemObects for the first 15... then read in the item sub documents...  now all your data is in a consistent format...  use that to present and work with the web browser...  just "deconvert" when you need to save...  so the first 15 objects go back to the main doc in the array thing... and any more go back to sub documents....  just thinking out loud...

Now if you're not doing java...  I bet you could pull it off with a bunch of SSJS functions...  

I don't understand this statement:  "I'm looking for different methods to either acquire the data without nested repeats or processing the information. "

I use a lot of nested repeats... but I don't try to get the data from the repeat itself...  I'll use functions and the domino object model to get what I need.

You could certainly write a function to create an array to through into scope...  but what kind of array? You can put a javaScript array in there.. but there are so many java objects that might help you like java.util.arraylist..

 

Just some random thoughts at the moment.

Dave

Aug 20, 2013, 8:53 PM
453 Posts
One way of maintaining contact to the dataSource

You can store the actual dataSource in a scope variable. Depending on when you might need it you could use either a viewScope or sessionScope. The process is dead simple. On your XPage on the beforePageLoad add this code

viewScope.put("vsMainDataSource", document1) ;

where vsMainDataSource id the name of scope variable containing the dataSource and document1 is the name of your dataSource. Set it as a sessionScope if the processing is to be done after the dataSource has expired. I use this also when I have two dataSources on a single Xpage and I need to pass information back and forth between the dataSources. It also allows me to save both dataSources or just one. Works pretty neat. Got this tip from StackOverflow (Thanks you). This is one of those things that I wished I had learned day one because it would have made my design much easier, might go back and clean up some of the places.

Bill

Here is a link to a previous string that develops this a little further:

http://www-10.lotus.com/ldd/xpagesforum.nsf/xpTopicThread.xsp?documentId=EAB54C114F61B79D85257BC3006BA313

Aug 21, 2013, 2:39 PM
10 Posts
Answers to the Questions

David and Bill

Mostly in SSJS, I'm just starting out in Java, taking a TLCC course.  Notes Database is Purchase Request that I wrote about 12 years ago.  All the fields are single value.  The main document has the first 15 line items with sequential item group by 15 items in response documents. The line item fields are in a subform that is used in both main and response documents of the purchase request.

There will be two databases, the original Purchase Request and new xpages application.

Our CFO likes the Purchase Request application/db so much he wanted to incorporate the Purchase Orders in it as well.  I already done that.  Now he want the a shipping receipt that the end user fills out with the actual quantities received.

What I need to do is store the information that end user enters for the shipping receipt and store that information, and sum those quantities back into the purchase request document.  There can be multiple shipping receipts to handle partial supplied orders.  This gives them a record of who, what and when items was received.

My thought was to present the line items to end user with a received quantity input.  Then processing those values, summing those values back into the purchase request and writing the line items detail alone with quantities entered into a shipping receipt document. 

My problem is understand how to process the quantities, when the values are not bound to any datasource yet.  Or maybe I'm just not thinking problem through correctly.

Here a prototype code I did using nested repeats generating the Notes field names to bind too.  The back end form has 8 fields fItem01, fPD01, fRQR01, fTRQR01, fItem02..., fItem03, fPD03 so on.  all single value text

The two buttons I have reads the inputText values and the other get the value by component.  The second time the "Read Componients" is executed I get  a exception on the rowData var.

Thanks both you for your comments.

    <xp:this.data>
        <xp:dominoView var="view1" viewName="vwMultItem"
            ignoreRequestParams="true">
        </xp:dominoView>
        
    </xp:this.data>
    <xp:panel>
        <xp:table>
            <xp:tr>
                <xp:td></xp:td>
                <xp:td></xp:td>
            </xp:tr>

            <xp:repeat id="repeat1" rows="30" value="#{view1}"
                var="rowData" indexVar="rowIndex" repeatControls="true" first="0">
                <xp:panel id="panelRepeatData">
                    <xp:this.data>
                        <xp:dominoDocument var="document1"
                            action="openDocument"
                            documentId="#{javascript:rowData.getNoteID();}"
                            formName="frMultItem" ignoreRequestParams="true">
                        </xp:dominoDocument>
                    </xp:this.data>
                    <xp:tr>
                        <xp:table>
                            <xp:repeat id="repeat2" rows="3"
                                var="rowItem" first="0" repeatControls="true"
                                indexVar="cptIndex">
                                <xp:this.value><![CDATA[#{javascript:["01", "02", "03"]}]]></xp:this.value>
                                <xp:tr>
                                    <xp:repeat id="repeat3" first="0"
                                        rows="3" var="fieldName" repeatControls="false">
                                        <xp:this.value><![CDATA[#{javascript:["fItem"+rowItem,"fPD"+rowItem,"fRQR"+rowItem]}]]></xp:this.value>
                                        <xp:td>
                                            <xp:text escape="true"
                                                id="computedField1" value="#{document1[fieldName]}">
                                            </xp:text>
                                        </xp:td>
                                    </xp:repeat>
                                    <xp:td>
                                        <xp:inputText
                                            id="inputText_${rowIndex}_${cptIndex}">
                                        </xp:inputText>
                                    </xp:td>
                                </xp:tr>
                            </xp:repeat>
                        </xp:table>

                    </xp:tr>
                </xp:panel>
            </xp:repeat>
        </xp:table>
    </xp:panel>
    <xp:panel id="panelResult">
        <xp:table>
            <xp:tr>
                <xp:td>
                    <xp:button value="Read inputText" id="button1">
                        <xp:eventHandler event="onclick"
                            submit="false">
                            <xp:this.script><![CDATA[alert("start");
//var domEl = dojo.byId('repeat3');
var domEL = dojo.query("tbody tr td input");
//alert("domEL value " + domEL[0].value);
var values = "";
dojo.forEach(domEL, function(node){
    values += node.value + " "
});
alert( "values    " + values);
//var textBoxes = domEl[0].value;

//var certainValue = textBoxes[0].value;
//alert("Value of component " + certainValue);]]></xp:this.script>
                        </xp:eventHandler>
                    </xp:button>
                </xp:td>
                <xp:td>
                    <xp:button id="button2" value="Read Components">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="partial" refreshId="panelResult">
                        <xp:this.action><![CDATA[#{javascript:sessionScope.cpValue = "Test";}]]></xp:this.action>
                    </xp:eventHandler></xp:button>
                </xp:td>
            </xp:tr>
            <xp:tr>
                <xp:td>
                    <xp:text escape="true" id="computedField2"
                        value="#{sessionScope.cpValue}">
                    </xp:text>
                </xp:td>
            </xp:tr>
        </xp:table>
    </xp:panel>

 

Aug 21, 2013, 3:35 PM
586 Posts
funny...

I pretty much did this exact application at my last job...  all notes client... no xpages...  even added in some payment functionality so they could compare to the corporate credit card statement....  funny stuff...  :)

Thinking out loud here....

First...  it would be awesome if you could go xpages only for this...  the biggest problem you have is dealing with different formats for the line items...  the first 15 are on the mainDoc... and the rest are in subDocs...  so that's just tough to deal with...

Here's how I THINK I would approach this:

For the 15 fields...  don't try and do a repeat control or anything...  just put them on the xpage manually like you would a notes form...  that's the easiest thing...  I would probably add a field called qtyReceived or something like that to your notes form for EACH line item...  This gives the user a place to enter that for the line item and you can then save it.

Make your subdocuments for the lineitem...  including the new field... that repeat can go right under the 15 line table ...  so you can likely get it to look "close to 1 table" I'd think...  Note I keep saying sub documents..  I've never used a true response document in xpages and I never will...  I'd rather just share keys...  but that's up to you...

So in theory you have an xpage with all your line items...  I see you're trying to use Dojo for something...  I wouldn't use Client side JavaScript for any part of this personally... not the core logic at least...

I GUESS you want near the top maybe something like QTY Ordered as well as QTY Received...

I would create a SSJS function to get those numbers...  Write in in LoutsScript first if you need to and then convert... less intimidating  It's just the domino object model...  but in the function grab your document (pass it in maybe) - and add up all the hardcoded values...  then do a getAlldocsbykey to get the sub docs... loop through and get all those totals...  don't forget to recycle() as outlined in the xpagescheatsheet...  loops need recycling...

 

Anyway - knowing as little as I know about this app...  that is how I would probably approach it...

 

Hope that helps!

Dave

Aug 21, 2013, 5:11 PM
10 Posts
same here

That's where my thoughts are going.  Make a custom control for the 15 line item.  I already have received qty field added from beginning.

Then I can possible pass the datasource to CC.  My question/thinking is I need to write only the received qty back to purchase request, but write line item details plus the qty received to another document (call it shipping receipt).

Just wondering what would be best method in handle reading the data from one source then writing to another source.

Note: I wanted to rewrite the whole application in xpages changing the structure to a subdoc for each line item, but CFO (layer 8) didn't want me spend time doing that. 

thanks for your thoughts

Bob

 

Aug 21, 2013, 5:26 PM
586 Posts
hmm

Give the CEO this scenario...  he has a problem with the engine of his 2002 Ford Taurus.  He takes it to the shop.  They can spend some time fixing it up and give him the back the engine and body or a 2013 Ferreri.  Or they could spend less time and just give him the engine.  Which would he prefer?  

:-)

Remember not everything has to be a custom control.....  so those first 15 line items could be just on the xpage.  no datasource passing or anything needed.  It's unlikely you'll reuse this custom control....

Aug 21, 2013, 8:31 PM
453 Posts
I agree with Dave

I have a product that was developed in traditional N/D back in 1996/97 which is installed in hundreds of companies world wide. Earlier this year I decided to make the step to XPages. My first consideration was to make it so that it would function in a traditional Note Client or XPages. Very early on I figured out that that would involve a lot more work than write an agent that would reformat the data in an existing Notes Client data to conform to the XPages design.

Frankly, I think that trying to have both running side by side will end up costing way more than developing it in XPages only and work out a process to migrate the data. Plus you only have to maintain one design, and you will be happier with the XPage only application than a cobbled together Notes Client Xpages design.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal