RE: How to get click event from web screenlet

thumbnail
Prakash Kumar Singh, modified 7 Years ago. Junior Member Posts: 85 Join Date: 1/30/15 Recent Posts
Hi
i am using web screenlet version 3.1.0 in android. it rendering my current url and showing web content display portlet .Web content display has liferay document url. When i am clicking this url , nothing is happening . If i render same url in android webview and click same document url, it redirects to browser ,means i am able to get this url in click event but not in web screenlet .

Then my question is .How to get value of internal click event in web screenlet ?

Regards

Prakash
thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts
Hey!

You can inject a script in the WebScreenlet to detect the click event and then communicate with the native part to perform some action.

You have to create a script in js that handles the click event and call the method
window.Screens.postMessage('clicked', <data-that-will-be-received-in-native>)</data-that-will-be-received-in-native>


After doing this, you will have to implement the WebScreenlet listener in your activity. You will receive the message from js in the method onScriptMessageHandler. In that method you can perform the action you need with the data received

You have documentation about the webScreenlet here and here

I hope it helps emoticon

Regards,
thumbnail
Prakash Kumar Singh, modified 7 Years ago. Junior Member Posts: 85 Join Date: 1/30/15 Recent Posts
Victor Galan:
Hey! You can inject a script in the WebScreenlet to detect the click event and then communicate with the native part to perform some action. You have to create a script in js that handles the click event and call the method [code]window.Screens.postMessage('clicked', )[/code] After doing this, you will have to implement the WebScreenlet listener in your activity. You will receive the message from js in the method onScriptMessageHandler. In that method you can perform the action you need with the data received You have documentation about the webScreenlet [url=https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/rendering-web-pages-in-your-android-app]here[/url] and [url=https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/web-screenlet-for-android]here[/url] I hope it helps :) Regards,

 

Injecting a script in both iOS and Android works only first time when page loaded. If the page refreshed than it doesn't work. Here I have shown an example in this video link.  https://drive.google.com/open?id=1Q0fCWZ3U2naRHEGhXbrapmLcNyqA7TXN

 

Thanks

 

 

 

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

What version of Liferay Screens are you using? This was fixed in the latest version (4.0.0)

Can you try that version and check if the issue still exists?

 

Regards

thumbnail
Prakash Kumar Singh, modified 7 Years ago. Junior Member Posts: 85 Join Date: 1/30/15 Recent Posts
Victor Galan:

What version of Liferay Screens are you using? This was fixed in the latest version (4.0.0)

Can you try that version and check if the issue still exists?

 

Regards

 

issue still exist with latest version of screen 4.0.0 

 

 

 

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

Hi!

So, to be able to reproduce it, how are you reloading the page?

The video you shared is private

 

Regards

thumbnail
Prakash Kumar Singh, modified 7 Years ago. Junior Member Posts: 85 Join Date: 1/30/15 Recent Posts
Victor Galan:

Hi!

So, to be able to reproduce it, how are you reloading the page?

The video you shared is private

 

Regards

 

Now video is accessible for you. Please check video once more.

 

 

 

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

Hi!

I've just saw the video, for keeping a script while navigation throught SPA, you have an utility function in the Screens global object, basically you have to pass the function that you need to preserver when SPA navigation happens.

 

You have to do this in your case: 

window.Screens.addScreensScript(modifyItem);