Display Flash Banner in Hippo Cms Site - java

I am customizing the go green site , here I want to display a flash banner in the header part.
For this I did the following
In the hst:channelinfo added new property (headerFlashBanner) and
path for that (/content/assets/Flash/2010/windymobility.flv).
In the WebsiteInfo.java added the following code :
#Parameter(name = "headerFlashBanner")
#JcrPath(
pickerInitialPath = "/content/assets/Flash/2010"
)
String getHeaderFlashBannerPath();
In WebsiteLogo.java I did the following:
Fetched the flash doc path with the WebsiteInfo object
final String headerFlashBannerPath = info.getHeaderFlashBannerPath();
Here I did an System.out to print banner path but it is not showing any path and no exception is occuring.
Please help me how I can display the flash banner on my website.
Please mention what's need to do for displaying flash banner on website.What will be the code changes or what new classes I need to create.

I don't think a System.out in this case will reach the console, better to use a logger or set a breakpoint and check the value.
What you could do is put the path on the request. In your jsp you can then put the tags for displaying the flash. Actually you probably want to put the url on the path not the repository path. Or you can use the hst:link tag.

Related

How to get active Google profile name when I get the active Url from google chrome browser using C#

iam using this code to get the currently active tab open URL from Google Chrome browser.
public static string GetActiveTabUrl()
{
Process[] procsChrome = Process.GetProcessesByName("chrome");
if (procsChrome.Length <= 0)
return null;
foreach (Process proc in procsChrome)
{
// the chrome process must have a window
if (proc.MainWindowHandle == IntPtr.Zero)
continue;
// to find the tabs we first need to locate something reliable - the 'New Tab' button
AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar"));
if (SearchBar != null)
return (string)SearchBar.GetCurrentPropertyValue(ValuePatternIdentifiers.ValueProperty);
}
return null;
}
is there any way that I can return the current Profile name too? the profile name which I mean is found on the upper right part of the google chrome browser so it maybe has more than a profile with different names I want only to get the current name with the URL it comes from this function. I can open or use many profiles at the same time in google chrome, so I want to get the active Tab URL and the profile name with it or the email of that profile.
this an image of the profile name i want it from chrome to be sent with the currently active tab URL.
so i expect something like that for example to be done in c# to get the profile name
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "profile email"));
last thing it can be c# or java codes if it can be better do in it also any solution that can get it in any programming language, please help with any information.
Thanks in advance.
You are going to have to dive into the HTML a little bit. Use chrome's developer features and inspect the HTML. You will find what class the username is under and the text is stored as the title find an example below.
<a class="gb_b gb_ib gb_R" href="https://accounts.google.com/" role="button" tabindex="0" title="Google Account: FillerFirstName FillerLastName (fillerEmail#gmail.com)" aria-expanded="false"><span class="gb_db gbii"></span></a>
You can accomplish this in many different ways with C#. I would recommend Selenium.

Appium with Android Hydrid App doesn't recognise element

I am writing automation tests for a Hydrid App on Android. I have 2 problems:
From Appium Inspector, I see an element with attribute
resource-id: login_button
so I click this button with
androidDriver.findElement(By.id("login-button")).click();
and I get this error:
"An element could not be located with..."
Of course if I find element with
classname "android.widget.Button"
then it works. I asked developer, normally, resource-id would be like
resource-id: <APP_PACKAGE_NAME>:id/login_button
But he said for hydrid app he doesn't have bundleID (APP_PACKAGE_NAME). Is it correct that we don't have bundleID for Hydrid APP? And why Appium Inspector can see
"resource-id: login_button"
but this element could not be found and clickable?
So I also tried to switch context to WEBVIEW, with this code:
Set<String> contextHandles = appiumDriver.getContextHandles();
Map<String,String> hashMap= new HashMap<String,String>();
for (String contextname : contextHandles){
if (contextname.contains("NATIVE")){
hashMap.put("native", contextname);
} else {
hashMap.put("webview", contextname);
}
}
//webview
androidDriver.context(hashMap.get("webview"));
contextHandles has 2 values: NATIVE_APP and WEBVIEW_<APP_PACKAGE_NAME>. But when I set context to webview, I get error:
"There is no such context"
Can anyone please help? Thanks
Hybrid application means - An application build by combination of both Native App View and Web View.
But at a time only one view will be available either Native or Web
If the view is Native, then you can inspect elements from UI Automator.
If the view is webview, then the UI automator will not show any hierarchy. For that you have to inspect in browser using the url - chrome://inspect/#devices
In your case you are saying that you are able to click on login if you use class name, but unable to click when you are using resource-id
There might be multiple locators having the same resource-id. Please check once and make sure you are using unique locator that might be Xpath or class name etc

IndexedDB work in Android native app

We've got application to view some specific materials. Among material types there is HTML5 presentation that is shown in WebView widget inside app. And now we need to get detailed information about this view (for example slide show duration, list element pick where it is available, etc).
It is what customer wants - we can't change it.
We decided to use IndexedDB inside HTML5 to store information locally. Now storing works (as I know :) ). Next problem is to get this information by app and it is not solved yet. Unfortunately google didn't help me.
How to get information from IndexedDB file if I know its path? Or do you know another way to transfer data from html to native app?
P.S. Writing custom browser could not be solution.
Update
Found solution to load file from JS. In chrome browser it automatically saves in downloads. In android app I'm setting to WebView object DownloadListener to listen file save event.
Catching save file works perfect. But the url path is looks like blob:file/... and I can't get info from it. Tried using ContentResolver, create File object, replace blob: string with nothing, start ACTION_VIEW intent - nothing helped.
Update
Tried to use DownloadManager and DownloadManager.Request - it throws following exception
java.lang.IllegalArgumentException: Can only download HTTP/HTTPS URIs: file:///fa4857ad-0e86-454a-a341-123729e9ece0
Same with blob:file uri.
Is it a requirement to use IndexedDB for communication?
If not, you could add a javascript interface. Simply pass on the data as JSON string and then decode it on the java side.
https://developer.android.com/guide/webapps/webview.html#BindingJavaScript
Mind security (don't allow the user to browse to different pages, sanitize incoming data, ...) ;-)
You can solve the problem by hack by calling the JavaScript function from Java and returning the required attributes in specific pattern. To implement this
Create the javascript function which will return the attributes in
specific pattern.
Create the WebChromClient and override onJsAlert() method. message
parameter of onJsAlert has the returned string of message. Parse the
message string to get the required attributes.
Call the JavaScript function from Java code to get the value.
final class MyWebChromeClient extends WebChromeClient {
#Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
result.confirm();
// Parse the message to get the required attributes
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
return true;
}
}
To call the JavaScript function to get the data use the below code. Here testFunction() is the fucntion which will return the data in string format.
webView.loadUrl("javascript:alert(testFunction())");
Create the instance of WebChromeClient and set in webview and also don't forget to enable the JavaScript.
WebView webView = (WebView)findViewById(R.id.web_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new MyWebChromeClient());
We decided to use ServerSocket for localhost as web server on device. And then Html sends to it http responce. May be using java script binding as wrote #Michael2 whould be better, but our solution was realized before his post. :-)

NPE when referring to application resources

I am trying to display an icon on a button using the code posted below. But at run time, the console shows an NPE and highlights the code posted despite I am sure that the icon I wish to display on the button is placed in that path.
Note: the .. in the path is just a short for writing the whole path.
Code
ImageIcon iconplay = new ImageIcon (ClassLoader.getSystemResource("L:\\..\\..\\..\\..\\..\\..\\..\\..\\..\\Play.png"));
This is not a system resource, so don't try to use the system class loader. Something more like the following will use the context class loader.:
URL url = this.getClass().getResource("/path/to/the.resource");
That path starting with a drive letter is wrong. It should be a path relative to the class-path.

Implementing MixedParamUrlCodingStrategy prevents my site from using CSS

I developed an application in Wicket with a CSS-styled left menu. Everything worked fine. Then, to get the URLs to be RESTful, I changed WicketApplication.java to use MixedParamUrlCodingStrategy. From then on, the style stopped working. I don't know where the problem is. I didn't change anything else. Here's my code:
mount("/site",PackageName.forPackage(WelcomePage.class.getPackage()));
//
mount("/download",PackageName.forPackage(AppDownloadApi.class.getPackage()));
// mountBookmarkablePage("push/reg", PushRegApi.class);
mountBookmarkablePage("push/send", PushMessageApi.class);
mountBookmarkablePage("device", DeviceprofileExportAsXML.class);
// mountBookmarkablePage("app/download", AppDownloadApi.class);
// mountBookmarkablePage("ds/export", ExportDataSource.class);
// mountBookmarkablePage("control/export", ExportAsXML.class);
MixedParamUrlCodingStrategy ds = new MixedParamUrlCodingStrategy(
"ds", ExportDataSource.class, new String[]{"name"});
mount(ds);
MixedParamUrlCodingStrategy control = new MixedParamUrlCodingStrategy(
"control", ExportAsXML.class, new String[]{"controlName"});
mount(control);
MixedParamUrlCodingStrategy app = new MixedParamUrlCodingStrategy(
"app", AppDownloadApi.class, new String[]{"appId"});
mount(app);
MixedParamUrlCodingStrategy pushReg = new MixedParamUrlCodingStrategy(
enter code here "push/reg", PushRegApi.class, new String[]{"appName",
"groupName","userName","password","deviceToken"});
mount(pushReg);
If I uncomment the comments, and remove MixedParamUrlCodingStrategy, then everything works fine. How can I have both RESTful URLs and my desired style?
This could be an issue with how you are linking your CSS into the pages. We had a simmilar issue when first starting as we had hardcoded the path to CSS into the page, but then when we changed the mappings of some pages the relative paths to the CSS files were nolonger valid.
I would suggest to use FireBug and check the Net tab to see if the CSS is loading, and if so what the contents of the request returns.
You may need to use something like the CSSPackageResource.getHeaderContributer to link the css to the page correctly.

Categories

Resources