0

I'm going crazy: I cannot access the selected value of a combobox in the onchange event:

<xp:comboBox id="comboBox1" value="#{sessionScope.groupBy}">
<xp:selectItem itemLabel="nothing" itemValue=""></xp:selectItem>
<xp:selectItem itemLabel="State" itemValue="state"></xp:selectItem>
<xp:selectItem itemLabel="CCType" itemValue="cctype"></xp:selectItem>

<xp:eventHandler event="onchange" submit="true" refreshMode="complete">
            <xp:this.action>
                <xp:executeScript>
                    <xp:this.script>
<![CDATA[
#{javascript:sessionScope.groupBy = getComponent("comboBox1").getValue();
print( getComponent("comboBox1").getValue() )}
]]>
</xp:this.script>
                </xp:executeScript>
            </xp:this.action>
</xp:eventHandler>
</xp:comboBox>

I want to store the value and reload the page to access the value I just submitted. I also tried getSubmittedValue() and value only. They always return null.

What is the trick here?

Oliver Busse
  • 3,375
  • 1
  • 16
  • 26
  • Oh oh... I tried this on a clean Xpage - and it works! I am afraid that using several ExtJS elements on the page causes this not to function any more... :-/ Does anyone have the combination of ExtJS elements, event binding and other stuff with the "normal" Xpage-stuff working? – Oliver Busse Apr 07 '13 at 02:38
  • Yeah, I proved it with my ExtJS-Page again: I left the grids but turned off the viewport/layout JS - and it worked. – Oliver Busse Apr 07 '13 at 02:48
  • If you want to try yourself please check this out: http://mardou.dyndns.org/Privat/osnippets.nsf/id/OBUE-96J5QH – Oliver Busse Apr 07 '13 at 03:21
  • At first glance, I'd guess that Ext's DOM manipulation is causing your combobox to end up outside of the HTML form element, which means that its data will never be sent back to the server unless you're sending it via manual XHR requests, etc. This answer is for a completely unrelated issue, but still might be of assistance: http://stackoverflow.com/a/15859393/1171761 – Tim Tripcony Apr 07 '13 at 07:14
  • 2
    P.S. Never ask the component for its value. I know everybody does, but it's wrong: you should ask the data instead. In your example, it's bound to a sessionScope variable, so just ask the sessionScope. If the data was posted correctly, it'll be there. A component's job is for allowing *users* to interact with data. *Code* should talk to data sources directly, not to components. – Tim Tripcony Apr 07 '13 at 07:18
  • Hi Tim! You are right, I also tried to use the datasource, but as the combo isn't a part of the form after Ext's manipulation, there is also no data submitted - I checked it out via Webdeveloper "View generated source" tool :-( – Oliver Busse Apr 07 '13 at 11:57

2 Answers2

0

I have a problem similar to that one but if I understand your quandary I may have a solution. You are trying to capture the value of a combo box field that you select correct? Here is the code for the combo box (name: POVendor). The view I'm drawing the list from is named "PLBV".

@DbColumn(@DbName(), "PLBV", 1)

Here is the code for the Computed field that captures the value of the selection in the combo box. Just do a partial refresh on the computed field from the combo box & it should work fine.

var item = document1.getValue("POVendor");

return item;

0

I was facing the similar issue, tried the below option and it worked for me.

Set the Server Options on the onChange event of the combobox to Full Update and check the option "Process Data without validation

This will give you the desired result.(Your sessionScope.groupBy will be set to the new selected value of the combobox.