0

I am observing some strange behavior with my Worklight 6.1 application. I have one page (login page), that does not show any jQuery stylesheet effects. The page does pull up and functionally it's fine, but it does not look like any of the rest of my pages.

Here's the odd thing.. When I look at the page in the Worklight designer, I see the page is rendered with the jQuery stylesheet. However, when I run this in preview mode or on a device the pretty button icons ad header (jQuery Mobile) are gone.

Here is what I am doing...

I have a application with one HTML file with two DIV tags, which are my two pages. I have an adapter that has a protected procedure with a security test applied. I have created a custom login handler to authenticate my application using a custom coded Java class. The handler will first check to see if the resource requested is protected and if so, it will (show / hide) the right DIV.

The application tries to call a protected resource within the init method, so at startup the application first throws up the login screen. This is where I see my problem. The really odd thing is that once I successfully log in, I am directed to a different page and that page is fine. It's just the login page that is not displaying correctly.

Here is my code in the challenge handler.

customAuthenticatorRealmChallengeHandler.handleChallenge = function(response){
var authStatus = response.responseJSON.authStatus;

if (authStatus == "required"){
    $('#addActivity').hide();
    $('#AuthBody').show();
    $('#passwordInputField').val('');
    if (response.responseJSON.errorMessage){
        alert(response.responseJSON.errorMessage);
    }
} else if (authStatus == "complete"){
    $('#AuthBody').hide();  
    $('#addActivity').show();
    customAuthenticatorRealmChallengeHandler.submitSuccess();
}
 };

Here is my HTML

<!DOCTYPE HTML>
<html>
        <head>
            <meta charset="UTF-8">
            <title>MobileTAcT</title>
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
            <link rel="shortcut icon" href="images/favicon.png">
            <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
            <link href="jqueryMobile/jquery.mobile-1.3.1.css" rel="stylesheet">
            <link href="jqueryMobile/jquery.mobile.theme-1.3.1.css" rel="stylesheet">
            <link href="jqueryMobile/jquery.mobile.structure-1.3.1.css" rel="stylesheet">
            <link rel="stylesheet" href="css/MobileTAcT.css">
            <script>window.$ = window.jQuery = WLJQ;</script>
            <script src="jqueryMobile/jquery.mobile-1.3.1.js"></script>
        </head>
        <body id="content" style="display: none;">
    <div data-role="page" id="addActivity">
        <div data-role="header" id="header" data-position="fixed">
            <h3>Add Activity</h3>
        </div>
        <div data-role="content" style="padding: 50px">
            <div class="ui-grid-solo">
                <div class="ui-block-a">
                    <label for="text">*Activity name:</label> <input type="text"
                        name="activtyName" id="activityName">
                </div>

                <div class="ui-block-a">
                    <label for="text">*Capabilities:</label><select name="capabil"  id="capabil">

                        <option value="option">One</option>
                        <option value="option">TWO</option>    
                    </select>
                </div>
                <div class="ui-block-a">
                    <label for="text">*Activity type:</label><select
                        name="activityType" id="activityType">
                        <option value="option">BLAH</option>
                        <option value="option">YO</option>

                    </select>
                </div>
                <div class="ui-block-a">
                    <label for="text0">MyNumber:<br>Leave field
                        blank
                    </label> <input type="text" name="sID" id="sID">
                </div>
                <div class="ui-block-a">
                    <label for="text">Customer name:</label><input type="text"
                        name="cName" id="cName">
                </div>
            </div>
            <hr>
            <div class="ui-grid-a">
                <div class="ui-block-a">
                    <a href="#addActivity" data-role="button" id="submitBtn">Submit</a>

                </div>
                <div class="ui-block-b">
                    <a href="#mainMenu" data-role="button" id="button3">Cancel</a>
                </div>
            </div>
        </div>
    </div>


<div data-role="page" id="AuthBody">
        <div data-role="header" id="header1" data-position="fixed">
            <h3>Mobile TAcT</h3>
        </div>
        <div data-role="content" style="padding: 50px">

            <div id="loginForm">
                    Username:<br/>
                    <input type="text" id="usernameInputField" /><br />
                    Password:<br/>
                    <input type="password" id="passwordInputField" /><br/>      
                    <input type="button" id="loginButton" value="Login" />
                    <input type="button" id="cancelButton" value="Cancel" />
            </div>

        </div>
    </div>


    <script src="js/initOptions.js"></script>
            <script src="js/MobileTAcT.js"></script>
            <script src="js/messages.js"></script>
            <script src="js/CustomAuthenticatorRealmChallengeHandler.js"></script>
        </body>
</html>

Here is what it looks like in Worklight Studio. (Nice and pretty)

Here is what I actually see when I run it in the simulator or preview mode. (Ugly and plain)

UPDATE

So.. I loaded this in Chrome and took a look a the developer tools. I see that there is a error when loading the page. Strange.. seems as thought there is an NOT AUTHORIZED ERROR

I had to post the link to the error message in the comments section because I am a newbie and I am only allowed to post 2 links. I can't quite figure out why this one page has problems loading the jQuery stylesheet. (See the link in the comments)

UPDATE 2

I have discovered some additional detail, but I still can't seem to figure this out.

I changed the default page (which is actually just a DIV tag within one HTML file) to a different page. I am puzzled as to why this is the case, but apparently the ONLY page that has the jQuery Stylesheet applied is the DEFAULT page. All other pages functionally work but the jQuery stylesheet is NOT applied. Why would that be? I can't figure out why…

grg
  • 5,023
  • 3
  • 34
  • 50
Dave Krier
  • 55
  • 6
  • So add a link to the image instead...? imgur, imageshack, some service... – Idan Adar Feb 12 '14 at 17:00
  • Great idea.... Just uploaded links to pictures!! – Dave Krier Feb 12 '14 at 17:34
  • Open the Chrome dev tools' console, what error do you see? – Idan Adar Feb 12 '14 at 17:35
  • Idan... Thank you for pointing me in the right direction. – Dave Krier Feb 12 '14 at 18:02
  • I don't have enough of a reputation to post more than two links in the page above. (The limitations you have when your a new user to the board is stupid) http://i.imgur.com/zCImaLO.png – Dave Krier Feb 12 '14 at 18:11
  • You can take a look at the FAQ for how to increase your reputation. Can you produce a small test case project and upload to Dropbox? – Idan Adar Feb 12 '14 at 18:19
  • About "update 2", you are probably not changing pages correctly, thus losing the Worklight context and anything else Worklight-related. See my answer to this question: http://stackoverflow.com/questions/21747801/ibm-worklight-6-1-why-is-cordova-code-not-working-when-placed-in-a-sub-page – Idan Adar Feb 13 '14 at 18:01

1 Answers1

2

I now have my application working as expected..

Here is the solution..

In my app I originally tried to change pages (just changing to show a different DIV in the same HTML) like below, but it wasn't rendering the page with the JQuery Stylesheet.

    $('#NewPage').show();
    $('#CurrentPage').hide();

I found that if I replaced my above code with this it all works as expected. I am now able to transition from the current page to the new page and all the elements in my page now are rendered with the JQuery Stylesheet

    $.mobile.changePage('#NewPage');
Dave Krier
  • 55
  • 6