WebView.refresh issue

Today when I tried to use WebView.refresh method, I found I always get pop up message "Error loading page", then the page seems OK.

Does anybody know the reason why I have this kind of issue?

Ariana Habbaba
Can you post the code where

Can you post the code where you use WebView.refresh? And any code that is associated with it as well.

Thanks

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steve Zhang
index.erb<div data-role="page

index.erb

<div data-role="page">

  <div data-role="header" data-position="inline">

   <h1>Test Refresh</h1> 

  </div>

 

  <div data-role="content">

    <a href="<%= url_for :action => :refresh%>">refresh</a>

  </div>

   

</div>

controller.rb

require 'rho/rhocontroller'

class RefreshController < Rho::RhoController

 

  def refresh

      WebView.refresh

  end

 

end

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Divyansh Madan
<div data-role="content">   


<div data-role="content">

    <a href="<%= url_for( :action => :refresh) %>">refresh</a>

  </div>

try this in your code instead of your button

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steve Zhang
I tested your suggestion, and

I tested your suggestion, and it definitely not working, 

since we know that for ruby parenthesis is optional.

Could you duplicate my issue in your environment?

Thanks

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ariana Habbaba
Try def refresh     render

Try

def refresh

     render :action => :index

end

You can only use WebView in a callback method

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steve Zhang
The issue I found that if I

The issue I found that if I call render method, then the same page will be added the browser's history stack. if you click back, it will not go the the previous page.

so render will break my current solution

While WebView.refresh will not.

From the document, I did not see that WebView only works in the callback.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ariana Habbaba
Also, there is a variable in

Also, there is a variable in rhoconfig.txt where you can keep track of the last page visited.

See if you can take advantage of that

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steve Zhang
could you explain me how to

could you explain me how to use it?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ariana Habbaba
You can read up on how to use
Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ariana Habbaba
Your question from a few days

Your question from a few days ago.

https://developer.motorolasolutions.com/thread/1870

WebView is used in callbacks.

Maybe you can try calling a callback method from your refresh definition.

For example:

def refresh

     render :action => :refresh_callback

end

def refresh_callback

     WebView.refresh

end

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steve Zhang
I tried your code, it is not

I tried your code, it is not working.

Could you test on your environment to make it working.

I also check using the true callback

def refresh

  Rho::Timer.start(1000, (url_for :action => :refresh_callback), "")

end

def refresh_callback

  WebView.refresh

end

The browser will display an empty screen, which is the similar result I mentioned in my previous question. https://developer.motorolasolutions.com/thread/1870

I don't think WebView.refresh will work in the callback, because it has no idea what current page is.

Could you provide me the working sample code for WebView.refresh?

Thanks

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ariana Habbaba
Here, in your refresh method,

Here, in your refresh method, add the line at the end

redirect :action => :index

What will happen is that the index page will be shown and then refreshed when WebView.refresh is called.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steve Zhang
What is the point?  if I call

What is the point?  if I call redirect :action => :index, then there is no need to call WebView.refresh

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ariana Habbaba
What the redirect will do is

What the redirect will do is take you back to the index page. And then WebView.refresh will refresh it.

That way, I believe, you should be able to keep your stack of pages.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments