2

I use the value for 'first' on a repeat control to know where I was as

sessionScope.ssCat1First = getComponent("repeatCat1").first;

so I can set the Starting Index value to ssCat1First and I'm on the right page. However, under some conditions I need to reset first on the component

I tried

getComponent("repeatCat1").first.setValue(0);

but I get the error " Error calling method 'setValue(number)' on an object of type 'Number [JavaScript Object]'" So it looks like where I have 0 in need a Java Object? If so how would I do that?

Bill F
  • 2,057
  • 3
  • 18
  • 39

2 Answers2

1

You get a list of all properties and methods of Xsp components from JavaDoc Package com.ibm.xsp.component.xp.

How you can find the control's component class? Just print the object's class name to servers console with a button. For your repeat control example you'd write:

<xp:button
    value="Show class"
    id="button2">
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript:print(getComponent("repeatCat1"))}]]></xp:this.action>
    </xp:eventHandler>
</xp:button>

and console will show you something like
HTTP JVM: com.ibm.xsp.component.xp.XspDataIterator@20f620f6.

Now, look for class XspDataIterator in JavaDoc. This class doesn't have a method getFirst() or setFirst() but the parent class com.ibm.xsp.component.UIDataIterator has:

enter image description here

Keep in mind that getComponent("repeatCat1").first is the Expression Language version of getComponent("repeatCat1").getFirst(). That's what really gets executed.

The same applies to a pager. You'd look for XspPager and then for parents class com.ibm.xsp.component.UIPager. There you can see how to set the page number for a pager:

enter image description here

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
0

Use setFirst():

getComponent("repeatCat1").setFirst(0);
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • Thanks - is there a place where one can get a list of the properties and methods for various components. For example I need to set the page number for a pager – Bill F Feb 22 '15 at 14:48