how to display value of content in object in Java? I always get something like: org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor#1a28aef12019-10-13
#Bean
public XwsSecurityInterceptor securityInterceptor() {
XwsSecurityInterceptor securityInterceptor = new XwsSecurityInterceptor();
securityInterceptor.setPolicyConfiguration(new ClassPathResource("securityPolicy.xml"));
securityInterceptor.setCallbackHandler(callback());
System.out.print("toStringBean: "+securityInterceptor.toString());
//Security Policy -> securityPolicy.xml
return securityInterceptor;
}
I read that I should use toString() but I get same result. I just need value of properties inside object :)
You cannot read the properties of XwsSecurityInterceptor using toString method as it is not overridden in the class from Object class.If you want to see the value you better put a debug point in the class and inspect the values and run the application in Debug mode.
For Debug in intellij.
click on the bug button in below screenshot. For adding the dubug point just single click on line number. then a red dot appears on the line number. When you run the application. You can see execution stops at the point. Then right click on the variable and select Evaluate Expression and a popup opens. Just click on the evaluate button in the popup and you can see the different value of objects present in the class.
Related
I have a ComboBox in my Vaadin 8 code.
allAtts here is a Set of Attendant-s, and the field theAtt in there is of type String:
private ComboBox<Attendant> theCB = new ComboBox<Attendant>(null,allAtts);
theCB.setEmptySelectionAllowed(false);
Binder<SearchArgs> binder = new Binder<SearchArgs>(SearchArgs.class);
binder.setBean(sas);
binder.forField(theCB).bind("theAtt");
..
VerticalLayout vl = new VerticalLayout(theCB, rb, deleteBtn);
What's more - this exact flow of theCB is a copy-paste from another class i wrote, on the very same type Attendant.
The problem here is the drop-down click on theCB is not working. That is, clicking that little chevron-down icon on the ComboBox is producing no effect. What could this be!?
I tried removing the other items, rb, deleteBtn in vl. Still didn't work.
Nothing else happening to theCB anywhere else.
TIA.
EDIT:
theCB is otherwise functional. typing in the field is allowed, brings the choices and returns the selection accurately.
EDIT-2
https://github.com/vaadin/vaadin-combo-box/issues/680 is not the issue. nothing changing when i pass a non-null label value to the constructor. Besides, it's working fine with null label in that other place in the code.
EDIT-3
Attendant contains several fields, one of which is String att.
SearchArgs composes Attendant in a its field theAtt. Attendant.toString() returns att only.
Once again - this exact same logic is working, as i'm typing these, in another part in the code.
Also note: i since also tried the following without success:
binding theCB on a separate binder, i.e. declare a second binder on sas and use that one for binding theCB
cloning the Attendant objects that go into theCB as data-provider.
I'm using Selenium to check if error message shown when user sent form with empty fields. Error message block is attached to the DOM all the time, but when there is no errors it has "display: none;" style attribute. So, when I push the "save" button, I check if this block visible this way:
Assert.assertTrue("There is no validation error!", driver.findElement(By.id("validationModal")).isDisplayed());
And this works. But when I'm trying to check that messages in this block are showed, isDisplayed method always returns "false". When I use just this:
driver.findElement(By.id("validationModal")).findElement(By.tagName("ul"))
.findElement(By.xpath("//*[contains(text(),'Empty app name field')]"));
it goes fine, but it's wrong because it wouldn't throw an exception when this text will be not visible, but will be in page code. If I write this:
Assert.assertTrue(driver.findElement(By.id("validationModal")).findElement(By.tagName("ul"))
.findElement(By.xpath("//*[contains(text(),'Empty app name field')]")).isDisplayed());
it always fails. And I don't really understand why and how I can check, that text of error message is shown, right way.
UPD:
I've found the source of problem. This string finds not element inside "validationModal" block, but inside tag, which contains text we have to find.
driver.findElement(By.id("validationModal")).findElement(By.tagName("ul"))
.findElement(By.xpath("//*[contains(text(),'Empty app name field')]")).isDisplayed()
But I still not understand why it happens, because I specify the element where it should be searched for.
It seems that you are trying to interact with some modal frame.
Generally to interact with modal element you should change driver context first.
driver.switchTo().frame("ModelFrameTitle");
or
driver.switchTo().activeElement()
Find or check elements and then come back to main frame
driver.switchTo().defaultContent()
Try this :
Assert.assertTrue("Element is not displayed",driver.findElement(By.xpath("//*[contains(text(),'Empty app name field')]")).isDisplayed());
There was an error in xpath.
Wrong string was:
findElement(By.xpath("//*[contains(text(),'Empty app name field')]"))
And right is:
findElement(By.xpath("//li[contains(text(),'Empty app name field')]"))
Okay, this is very strange.
All I am having is a Hyperlink in my menu:
Hyperlink eventCalendar= new Hyperlink("Eventkalender", "eventCalendar=" + store.getId());
and I am listening to the ValueChangeEvent in the MainViewPresenter. Please notice that I am not doing anything. Right before the creation of the listener I am setting a SimplePanel to be the display for the ActivityManager:
App.activityManager.setDisplay(this.mainView.getMainContentContainer());
History.addValueChangeHandler(new ValueChangeHandler<String>() {
#Override
public void onValueChange(ValueChangeEvent<String> event) {
String historyToken = event.getValue();
GWT.log("onValueChange() historyToken " + historyToken);
}
});
But if I click the link what happens is this:
First, for the blink of an eye I can see the browser URL change to
http://localhost:8080/#eventCalendar=1
but it changes immediately back to
http://localhost:8080/#
which causes my landing page to get loaded inside the SimplePanel which I declared as display (see above).
Does anybody have an idea what could cause this behavior because this does not make sense to me? Why does the URL get changed again? Am I using History or Hyperlink wrong?
Most probably your PlaceHistoryMapper returns null for the eventCalendar=1 token, so it's replaced with the default place you gave to the PlaceHistoryHandler. If you're using GWT.create() based on PlaceTokenizers, with a factory and/or #WithTokenizers, that means either you don't have a PlaceTokenizer for the empty-string prefix (#Prefix("")), or that one tokenizer returns null.
That being said, you probably should rather try to use places directly rather than going through the history. That means using a ClickHandler on some widget and calling PlaceController#goTo with the appropriate place. Ideally, that widget would be an Anchor whose href is computed from the result of getToken from your PlaceHistoryMapper with the given place (how the href actually looks depends on your Historian; if you stick to the default behavior, then just prepend a # to the returned token).
Whenever you display a stack trace, you can get a "url-like" text which if you click it opens the appropriate class at the appropriate line.
Is there a possibility to output a text in a way that the console recognizes it and make it clickable like that?
But how would you format the output so it would recognize it as a "link" ?
You can't and you don't.
AndroidStudio supports that feature. You just need to call
exception.printStackTrace() and you should be able to click it in the console tab of IDE.
You will see something like
java.lang.Exception
at whatever.Test.main(Test.java:22)
The text inside the bracket will be highlighted and you can click it.
Based on #JEeemy's answer I managed to do this
public static void printLinkToThisLine() {
System.out.println(Thread.currentThread().getStackTrace()[3]);
}
I works for me ...
I don't know if you're using Eclipse, but the Eclipse console parses based on a pattern: FileName.java:lineNumber.
MyFile.java:3
Would link you to the 3rd line of whatever class you specified as MyFile.
You could use:
.getClass().getName()
to the the name of the file programmatically.
I have a invoice for which I want to show in preview mode with a watermark. I have integrated the report with my web application (Spring MVC).
Any solution?
EDIT: I want to pick a value from a dataset (Table: invoiceheader), and use that value to decide whether to show /not show the watermark. I am unable to pick that value from Birt script. Can you please please guide..
Sorry .. the customer asked for a different way of identifying the fact rather that from passing the parameter.
Thanks
You need to declare a report parameter in the .rptdesign of the invoice. For example we name it "useWatermark", and we set the datatype to boolean and a default value to true.
Select the report root in the outline view of the designer -> script tab -> beforeFactory
if (!params["useWatermark"].value){
reportContext.getDesignHandle().findMasterPage("Simple MasterPage").setProperty("backgroundImage", "");
}
This script removes the watermark if the parameter is set to false. By default, the master page is named "Simple Masterpage" but if you have renamed it or if there are multiple masterPages defined in the report you should adjust the script consequently.
EDIT: if we need to extract the information from a dataset, then we can't make use of the masterPage, we have to use a grid instead.
Create a grid with one cell, and drop all the content of your page into it
Set your watermark as background-image of the grid
Create a report variable "useWatermark" in the "Outline/variables" branch (see picture below), set default value to true/false as you like
Select dataset invoiceHeader -> script tab -> onFetch, and affect the variable from a boolean dataset column, or from any expression returning true/false:
vars["useWatermark"]=row["myBooleanDatasetColumn"];
This dataset must be used somewhere in the report body, otherwise it won't be triggered and the variable won't be initialized
Select the grid -> script tab -> onRender
if (!vars["useWatermark"]){
this.getStyle().backgroundImage="";
}