0
votes

I have a simple page inside mobile controls. I have an edit box and what I want to happen is to a partial refresh of the current in the onChange event of the edit control. Basically type something in the edit control - hit enter and do the partial refresh. What's happening is hitting enter if returning the page to the main menu. If I put a value in and hit TAB then it works as I would want.

I'm starting a new app from scratch. But I've done this concept many times with an app in production. I can't find anything special in the code that would "trap" an enter button... So I'm at a loss why I can't get the behavior I want this time around.

Here's a video demo of the problem: http://traffic.libsyn.com/notesin9/SO-Question2-HB.mp4

Below is the full code.

Thanks for any help!!

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"
    xmlns:xc="http://www.ibm.com/xsp/custom">
    <xp:this.resources>
        <xp:styleSheet href="/.ibmxspres/dojoroot/dijit/themes/tundra/tundra.css">
        </xp:styleSheet>
        <xp:styleSheet href="/mobile.css"></xp:styleSheet>
    </xp:this.resources>
    <xe:singlePageApp id="singlePageApp1"
        selectedPageName="mainMenu">
        <xe:djxmHeading id="djxmHeading1" label="My App"></xe:djxmHeading>
        <xe:appPage id="mainMenuID" pageName="mainMenu">
            <xe:djxmRoundRectList id="djxmRoundRectList1"
                title="Main Menu">
                <xe:djxmLineItem id="djxmLineItem9" moveTo="#container"
                    label="Test Page">
                </xe:djxmLineItem>
            </xe:djxmRoundRectList>
        </xe:appPage>
        <xe:appPage id="containerID" pageName="container"
            resetContent="true">
            <xe:djxmHeading id="djxmHeading5" label="My Page"
                back="Main Menu">
            </xe:djxmHeading>
            <xe:djxmRoundRectList id="djxmRoundRectList2">
                <xp:panel id="mainPanel">
                    <xp:table style="width:100.0%">
                        <xp:tr>
                            <xp:td style="width:50%"></xp:td>
                            <xp:td>Details</xp:td>
                        </xp:tr>
                        <xp:tr>
                            <xp:td>
                                <xp:inputText id="inputText1" styleClass="target alignVMiddle"
                                    value="#{sessionScope.myValue}">
                                    <xp:this.attrs>
                                        <xp:attr name="autocorrect" value="off"></xp:attr>
                                        <xp:attr name="placeholder" value="Tap to Scan...">
                                        </xp:attr>
                                    </xp:this.attrs>
                                    <xp:eventHandler event="onchange" submit="true"
                                        refreshMode="complete">
                                        <xp:this.action><![CDATA[#{javascript:viewScope.put("test", "test");}]]></xp:this.action>
                                    </xp:eventHandler>
                                </xp:inputText>
                            </xp:td>
                            <xp:td></xp:td>
                        </xp:tr>
                    </xp:table>
                    <xp:br></xp:br>
                    Current Value:&#160;
                    <xp:text escape="true" id="computedField1" value="#{sessionScope.myValue}"></xp:text>
                    <xp:br></xp:br>
                    <xp:br></xp:br>
                    Current Time:&#160;
                    <xp:text escape="true" id="computedField2" value="#{javascript:@Now();}">
                        <xp:this.converter>
                            <xp:convertDateTime type="time"></xp:convertDateTime>
                        </xp:this.converter>
                    </xp:text>
                </xp:panel>
            </xe:djxmRoundRectList>
        </xe:appPage>
    </xe:singlePageApp>
</xp:view>
2

2 Answers

2
votes

Can you do something like this to force a partial refresh on Enter?

<xp:inputText id="inputText1" value="#{sessionScope.myValue}">
    <xp:eventHandler event="onkeypress" submit="true" refreshMode="partial" refreshId="something">
        <xp:this.script><![CDATA[//partial refresh on Enter
            if( thisEvent.keyCode === dojo.keys.ENTER ){
                dojo.stopEvent( thisEvent );
            } else {        
                return false;
            }
        ]]></xp:this.script>
    </xp:eventHandler>
</xp:inputText>
0
votes

I think the problem is that enter will try to do a submit and submit will return you to the first page. Try to add a check in onkeyup or down for charcode 13 and if this is found return false. You might also need to do a stopproprigate or something like that. Google for enter key submit form

From my mobile ;-)

Or perhaps this post. http://tinyurl.com/bsgy9g6