Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to get click event from web screenlet
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
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

Regards,
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
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
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
Hi!
So, to be able to reproduce it, how are you reloading the page?
The video you shared is private
Regards
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.
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);
Powered by Liferay™