LWUIT HtmlComponent NoSuchElementException - java-me

I'm getting HtmlString From Rss File after parsing.I want to remove all html tags and need to display only the pure text on my Form,For that I've referred LWUIT HtmlComponent Class and I used below code:
private void displayCompleteNewsScreen(News detailNews) {
html.removeAll();
form2.removeAll();
form2.repaint();
form2.addCommand(m_backCommand);
form2.addCommandListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
form1.show();
}
});
String content= detailNews.getDescription();
html.setPreferredSize(new Dimension(300,300));
html.setHTML(content, null, null, false);
form2.addComponent(html);
form2.show();
}
I'm able to display the text successfully on my LWUITform ,but I'm throwing the below Exceptions Every time when i display my Text on Form
Exception1:
Uncaught exception: java.util.NoSuchElementException
at java.util.Vector.lastElement(Vector.java:456)
- com.sun.lwuit.html.HTMLComponent.popContainer(HTMLComponent.java:3667)
- com.sun.lwuit.html.HTMLComponent.processTag(HTMLComponent.java:2825)
- com.sun.lwuit.html.HTMLComponent.rebuildPage(HTMLComponent.java:1653)
- com.sun.lwuit.html.HTMLComponent.documentReady(HTMLComponent.java:1113)
- com.sun.lwuit.html.HTMLComponent$1.run(HTMLComponent.java:770)
Exception2:
Uncaught exception:
java.lang.OutOfMemoryError
(stack trace incomplete)
java.lang.OutOfMemoryError
(stack trace incomplete)
Exception3:
Uncaught exception: java.lang.IllegalArgumentException: Component is already contained in Container: Container[x=0 y=0 width=0 height=0, layout = BoxLayout, scrollableX = false, scrollableY = false, components = [Container]]
- com.sun.lwuit.Container.insertComponentAt(Container.java:370)
- com.sun.lwuit.Container.addComponent(Container.java:334)
- com.sun.lwuit.html.HTMLComponent.newLine(HTMLComponent.java:1878)
- com.sun.lwuit.html.HTMLComponent.processTag(HTMLComponent.java:2826)
- com.sun.lwuit.html.HTMLComponent.rebuildPage(HTMLComponent.java:1653)
- com.sun.lwuit.html.HTMLComponent.documentReady(HTMLComponent.java:1113)
Note:My HtmlString will not Contain any Image and src Tags
can any one help me...

There seems to be a parse error in the HTML code. Is it a full set of HTML containing the actual HTML tag, body etc.?

Related

Appium: Unable to find element in Android chrome browser by ID and Name, getting "InvalidArgumentException"

I'm using Appium (v1.15.1) to find email a password fields from "http://facebook.com" with Chrome browser on Android device, and i'm unable to find email and password fields elements using method findElementById('') and findElementByName(''). I've tried to find it using XPath and it works.
This is my code:
public class Browse extends BaseMobile {
public static void main(String[] args) throws MalformedURLException {
AndroidDriver<AndroidElement> driver = capabilities();
driver.get("http://facebook.com");
driver.findElementById("m_login_email").sendKeys("prueba#mail.com"); // not working
driver.findElementByName("pass").sendKeys("123456789"); // not working
driver.findElementByXPath("//*[#name='login']").click();
}
}
capabilities:
public class BaseMobile {
public static AndroidDriver<AndroidElement> capabilities() throws MalformedURLException {
AndroidDriver<AndroidElement> androidDriver;
String serverUrl = "http://127.0.0.1:4723/wd/hub";
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android device");
cap.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
androidDriver = new AndroidDriver<AndroidElement>(new URL(serverUrl), cap);
androidDriver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
return androidDriver;
}
}
Error:
Exception in thread "main"
org.openqa.selenium.InvalidArgumentException: invalid argument:
invalid locator
(Session info: chrome=79.0.3945.136)
EDIT(1): As suggested I printed page source and I'm getting it without any problem. Added appium log too.
console log: System.out.println(driver.getPageSource());
Appium log
After driver.get("http://facebook.com"); line try to print page source and see if it is getting page source or not. Try System.out.println(driver.getPagesource());

Fail to assign Xpath value to string

I just tried to assign the value which i got from html page into a string but it failed at the the method Application_UnhandledException in App.xaml.cs
Though I'm new to WP8, please help me to understand the reason and fix it.Thanks everyone.
My code:
HtmlAgilityPack.HtmlNode imageNode = doc.DocumentNode.SelectSingleNode("//div[#class='fck_detail width_common']/table/img[#src]");
string imgUrl = imageNode.Attributes["src"].Value;
Failed at Application_UnhandledException in App.xaml.cs
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
After few days,i figured out this. Just need to fix the behavior of xml by 1 line before you load the Html document by below code
HtmlAgilityPack.HtmlNode.ElementsFlags.Remove("img");

Popup window Label is not getting loaded

1.Trying to display exception message in popup window. Exception message is not appearing.
2.Eg: When i click button a popup window (Second fxml file) is to load with proper exception message in the label
3.Popup window is appearing, But the Label is not loading (Bold one --> ExceptionLabel.setText("Please enter Proper file path")) it says null pointer exception.
4.I am not sure what i missing. Same declared in FX:ID and also in second fxml file linked the main controller. Thanks in advance.
#FXML
public Label ExceptionLabel;
Stage PopupWindow = new Stage();
public void Buttonhandle(ActionEvent event) throws IOException {
try {
if(ESBOutboundFile!=null && OutputFile!=null){
String Output = SBlogpaser.Logpaser(ESBInboundFile,ESBOutboundFile,OutputFile);
System.out.println(Output);
}else{
Window(PopupWindow);
**ExceptionLabel.setText("Please enter Proper file path");**
}
} catch (Exception ex) {
System.out.println(ex);
}
}
public void Window(Stage Popup) throws Exception {
this.Popup=Popup;
final FXMLLoader fxmlLoader = new FXMLLoader();
Parent root= fxmlLoader.load(getClass().getResource("POPUPWindow.fxml"));
Scene scene1 = new Scene(root);
Popup.setScene(scene1);
Popup.show();
}
If i keep the label in "OK" handle button it is getting displayed.
From where are you expecting ExceptionLabel to be instantiated?
Assuming you are pointing the fx:controller attribute of the root of your POPUPWindow.fxml file to the current class, it will just create a new instance of that class, and inject values into that instance. The field ExceptionLabel in the current instance won't be initialized.
You could probably just about make this work by setting the controller of the FXMLLoader to the current object, something like this:
public void window(Stage popup) throws Exception {
this.popup=popup; // why?
final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("POPUPWindow.fxml"));
fxmlLoader.setController(this);
Parent root= fxmlLoader.load();
Scene scene1 = new Scene(root);
popup.setScene(scene1);
popup.show();
}
and then remove the fx:controller attribute from POPUPWindow.fxml.
This seems like a really bad idea, though, because now the current object is acting as a controller for two different FXML files. This will be confusing at best, and under fairly reasonable conditions would produce weird results. It would be much better to write a different controller class for the popup:
public class PopupController {
private final String message ;
#FXML
private Label exceptionLabel ;
public PopupController(String message) {
this.message = message ;
}
public void initialize() {
exceptionLabel.setText(message);
}
}
and then use the window(...) method above, but with
fxmlLoader.setController(new PopupController("Please enter Proper file path"));
Obviously, if you're reusing the window(..) method, you might want to pass the message in as a parameter to that method.

Bind SCA Component Properties In Waveform Control Panel

I am trying to create a Waveform Control Panel to change the properties of its components. I attempted to apply the example in the Redhawk documentation for a Component Control Panel, but for some reason I get a java.lang.NullPointerException when running the plugin. The error occurs when I attempt to bind the text field to a component property, the exact line where the error occurred is in the comments of the code (at the very bottom).
public class TestControlPanel extends AbstractScaContentEditor<ScaWaveform> {
private ScaWaveform waveform;
private ScaComponent myComponent;
private Text propertyValueField;
private EMFDataBindingContext context;
/**
* {#inheritDoc}
*/
#Override
public void createPartControl(final Composite main) {
main.setLayout(new GridLayout(2, false));
Group controlGroup = new Group(main, SWT.SHADOW_ETCHED_OUT);
controlGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
controlGroup.setText("Controls");
createControlGroup(controlGroup);
}
private void createControlGroup(Composite parent) {
parent.setLayout(new GridLayout(2, false));
EObject input = getInput();
if (input instanceof ScaWaveform) {
// make local copy of waveform
waveform = (ScaWaveform) input;
try {
waveform.refresh(null, RefreshDepth.FULL);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
label = new Label(parent,SWT.None);
label.setText("Property Value:");
propertyValueField = new Text(parent, SWT.BORDER | SWT.FILL);
myComponent = waveform.getScaComponent("myComponent_1");
if(myComponent != null)
{
IObservableValue observable = SCAObservables.observeSimpleProperty(myComponent, "propertyId");
IObservableValue targetObservable = WidgetProperties.text(SWT.Modify).observeDelayed(5000,propertyValueField);
if(observable != null && targetObservable != null)
{
// ***** THE BELOW LINE CAUSES A java.lang.NullPointerException ERROR *****
context.bindValue(targetObservable, observable);
// ***** THE ABOVE LINE CAUSES A java.lang.NullPointerException ERROR *****
}
}
}
}
My original guess for the reason for this error was that one of the IObservableValue variables (e.g. targetObservable or observable) was null, which is why I check to make sure the values are not null before binding them. However, this didn't fix the problem and I still got the same error.
From what code I can see it seems as though your field varible "context" was never initialized.
Simply call the no argument constructor:
context = new EMFDataBindingContext();
It appears that the context variable is null. I see that you define "context" at the top of the class, but I didn't see where it has been set.

Play Framework 1.2.5 Excel Module Can't Parse Cell tag jx:forEach

Hi the following is my java method
public static void csvReport(String date) throws Exception
{
request.format = "xlsx";
renderArgs.put(RenderExcel.RA_ASYNC, true);
renderArgs.put("results", currentResults.values());
renderArgs.put("date", date);
render();
}
Then My view looks like
<jx:forEach items="${results}" var="result">
${result.simpleName} ${result.version} ${result.registerCount} ${result.uniqueAccess} ${result.totalAccess} ${result.updateCount}
</jx:forEach>
But when I run this, I get a NullPointerException due to a parse failure at item attribute which says Open quote at the attribute.
Any ideas?

Resources