Really need some help with an XPage repeat control

I am hoping that someone can offer me some helpful advice with repeat controls.

I am developing a basic little “shopping cart”-type custom control, where each row of the cart is represented by a line from a view. I have the repeat control setup properly, and the products appear exactly as I want them.

I have also added an edit box into the repeat control. This will allow the visitor to add the number of units they wish to order before clicking the “add to cart” button.

I have all of the necessary logic built to accumulate the items added to the cart in a sessionScope variable (thanks very much to Declan Sciolla-Lynch and his article on this here: Advanced XPages : Extending the sessionScope to store a hashmap | Dec's Dom Blog).

However, I am trying to determine how to reference the edit box on each row using server-side script. For instance, I can get a handle on the represented document ID by using the code: “var thisDocID = rowData.getUniversalID();”. I now need to get a handle on the associated edit box with an ID of “inputText1”.

I’ve also been toying with the idea of displaying a dialog box to collect the qty (instead of an individual edit box on each row), and have been using Declan’s blog as well as Jeremy Hodge’s examples over on the XPage Blog (サッカー ユニフォーム 安い – xpagesblog.com | 安いジャージを買う。 21.99 という安いジャージ。 ファンに最高のコレクションを提供します。 安心してお買い物をしてください。) to give this a go using client-side script. Can anyone comment on the best method of achieving this? I’m sure many have gone down this path before - Is there anything I should really watch out for/avoid? This is going to be quite a small “store” so volume is not really an issue for me. However, I’d like to stick with “best practices” so that my solution can scale should I need to migrate the logic into a larger project.

I hope that is descriptive enough to allow someone much more experienced than I to give me a nudge in the right direction.

Thanks very much for any assistance that you may be able to provide!

T.

Subject: Repeat, data table

Repeats are cool, but wouldn’t you rather use a data table? That said, I’ll tell you what I’ve done and you can figure out if it’s helpful.

I’ve got an application that uses a data table to display something similar to a shopping cart item, and I have one editable field in that data table, corresponding to your quantity. What I do is attach SSJS to the Key-onkeypress event and Select & Change-onchange events to update the value immediately. Saves me from having to gather changes. Oh, you have to put client-side JS in the Key-onkeypress to exclude all keypresses except return:

if (thisEvent.keyCode != ‘13’ ) {

return false;

}

I am loading the data for the XPage into a viewscope variable on load, and am doing a full refresh on the events listed above.

Subject: Found the answer…

I knew I should’ve looked a little harder before posting!

Thanks for your feedback Erich, but I do like to use repeat controls. I believe I would have had the same issues had I used a data table as well.

What I was looking for was the command: getComponent

So, to easily retrieve the value of a named edit box in a repeat control, I simply used the command…

getComponent(“inputText1”).getValue();

… and it worked perfectly.

Now, it’s on the to the next hair-pulling challenge:

If anyone can tell me how to set sessionScope variables using client-side script, that would be magnificent!

Here’s a link to that new topic: http://www-10.lotus.com/ldd/nd85forum.nsf/0/95031d752b6e38328525770000249c28?OpenDocument

Cheers,

T.