Wicket and Netbeans - some files are not openning - java

I have a Wicket page that simply not opens on Netbeans anymore, sometimes the HTML file and sometimes the .java file of the page, but never both opens together. I have to open the files on other editor.
The weird is that the page is rendered and works fine. Any idea why?
It gives me a strange log, that don't helps to track the error:
java.lang.NullPointerException
at org.netbeans.modules.web.wicket.tree.ComponentIdFinder.visitNewClass(ComponentIdFinder.java:67)
at org.netbeans.modules.web.wicket.tree.ComponentIdFinder.visitNewClass(ComponentIdFinder.java:34)
... log continues
I found this list of issues on Netbeans report with other devs with the same problem: Netbeans issues list.

Debugging manually the files I realized that the problem was in a DropDownChoice filled dynamically:
DropDownChoice addressesChoice = new DropDownChoice<>(
"address",
new PropertyModel(getModel(), "address"),
new ArrayList<Address>(),
new ChoiceRenderer<>("zipCode")
);
Adresses choices were filled dynamically based on selection of other DropDownChoice. The problem was with the choices of addresses, that is with no reference. So I splitted it on declaration-instantiation steps:
ArrayList<Addresses> addressesList = new ArrayList<Addresses>();
...
DropDownChoice addressesChoice = new DropDownChoice<>(
"address",
new PropertyModel(getModel(), "address"),
addressesList,
new ChoiceRenderer<>("zipCode")
);
That fixed the problem.

Related

I can't create an external link (href) that open itself without the localhost:8080 in front of it

I'm trying to create a link (href) that open itself in a new page. Should be "simple".
That's the focus code:
if (propertybox.getValue(CandidatoLink.LINK) != null) {
Anchor anchor = new Anchor(propertybox.getValue(CandidatoLink.LINK),
propertybox.getValue(CandidatoLink.LINK));
anchor.setTarget("_blank");
return anchor;
}
This is to get the link from the database, like "www.google.com":
propertybox.getValue(CandidatoLink.LINK));
This is to get the link opening in a new tab of the browser:
anchor.setTarget("_blank");
It works all just fine: I can get the link opened in a new tab. The only problem is that the system think that's an intern page of the website and sees it as a Route! That's the problem. It will open a new tab with this link: http://localhost:8080/www.google.com
I can't remove the first part (http://localhost:8080/). Can someone help me?
I use Java 11.0.15, Vaadin 14 (Maven/Spring Boot) and my IDE is Eclipse 2022-06 (4.24.0).

Open a new instance of GWT app

I'm developing a GWT web App . Righ now I have one default EntryPoint: AppWeb.
The page works perfectly if I run it in the web browser:
http://localhost/AppWeb.
If I open a new tab, and write the same URL, the App works just fine as two instances.
Now, I just want that a simple button in my app open a new windows of the same app and same entry point, just like a new instance. But is not working. I'm using this:
Window.open("AppWeb?guiId=xxx", "_blank", "");
The problem is that the new tab is openen, but is not calling the onModuleLoad of the AppWeb entry point.
I think you could do it using an anchor http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/Anchor.html
Set the anchor target with
myAnchor.setTarget("_blank");
in your code and in the ui
<g:Anchor ui:field='my anchor' href='' text='click here to duplicate'/>
Note the empty href='' (because it would be appended to your current url).
I tried it and it calls onModuleLoad() when the entry point is called on the new tab.

Set the initial directory in SWT FileDialog

I'm working on an Eclipse RCP project and need to let the user select some file.
For convenience, based on some conditions, the initial directory of the file choosing dialog should be set prior to opening it.
As I'm bound to Eclipse RCP / SWT, I am working with the org.eclipse.swt.widgets.FileDialog.
The documentation of this FileDialog points out to use the setFilterPath(String string)-method which should do exactly what I need (see documentation).
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String [] {"*.html"});
dialog.setFilterPath("c:\\temp");
String result = dialog.open();
Unfortunately it is not working, at least not "every time".
I have currently no installation to check on it, but I'm quite sure that the feature would work totally fine on a Windows 200/XP/Vista machine.
I am working with a Windows 7 machine and I think I am suffering from the behaviour described here for lpstrInitialDir.
At least, this is exactly the behaviour I am facing: The path is good the first time I open the dialog, but the second time, the path is initially set to the last chosen path.
This seems to be convenient in most cases, but it is not in mine.
Can this be right?
If so, have I any chance on changing the behaviour according to my needs?
Thanks for any helping answer!
I ran into the same problem on Windows 10 and found a solution that seems to be working for me. A code snippet from the DirectoryDialog led to the right direction:
if (filterPath != null && filterPath.length() > 0) {
String path = filterPath.replace('/', '\\');
char[] buffer = new char[path.length() + 1];
path.getChars(0, path.length(), buffer, 0);
if (COM.SHCreateItemFromParsingName(buffer, 0, COM.IID_IShellItem, ppv) == OS.S_OK) {
IShellItem psi = new IShellItem(ppv[0]);
/*
* SetDefaultDirectory does not work if the dialog has
* persisted recently used folder. The fix is to clear the
* persisted data.
*/
fileDialog.ClearClientData();
fileDialog.SetDefaultFolder(psi);
psi.Release();
}
}
The FileDialog misses this statement 'fileDialog.ClearClientData()'. My solution is to execute the following code before setting the path and open the dialog:
long [] ppv = new long [1];
if (COM.CoCreateInstance(COM.CLSID_FileOpenDialog, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_IFileOpenDialog, ppv) == OS.S_OK) {
IFileDialog fileDialog = new IFileDialog(ppv[0]);
fileDialog.ClearClientData();
fileDialog.Release();
}
Now you can set the filterpath without Windows messing things up.
I found a simple Solution for the Problem you described (I had the exact same Problem).
Just rearrange the your code like this:
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterPath("c:\\temp"); // This line is switched with the following line
dialog.setFilterExtensions(new String [] {"*.html"});
String result = dialog.open();
Somehow the Order of the methods called is relevant.
Are you using the same FileDialog object when you re-open it?
I ran a few quick tests and found that, if you re-set the filterPath, the dialog opens in the correct location.
If I open the same object again, it starts in the previously selected location.

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.

EXT-GWT Portal: How to get all Portlets?

Hi all this is my first Question here!
Im just making my first steps with (Ext-) GWT. I´m testing the Ext-GWT libraries and really: These are absolute great!
Now my question:
Is it possible to make a kind of "clear-Portal" or "hide all portles" for a defined Portal?
Or have i always manually clear the portal like in my example code above?
My sample code looks like this:
//define the Portal, 2 columns, each 50% auf width, with borders and Backgroundcolor
portal = new Portal(2);
portal.setBorders(true);
portal.setStyleAttribute("backgroundColor", "white");
portal.setColumnWidth(0, .50);
portal.setColumnWidth(1, .50);
//define a Portlet for showing all Users
portletUser = new Portlet();
portletUser.setHeading("Benutzer");
configPanel(portletUser);
portletUser.setLayout(new FitLayout());
CompUserList compUserList = new CompUserList();
portletUser.add(compUserList);
portletUser.setHeight(250);
//define a Portlet for showing all Vehicles
portletVehicles = new Portlet();
portletVehicles.setHeading("Fahrzeuge");
configPanel(portletVehicles);
portletVehicles.setLayout(new FitLayout());
CompVehicleList compVehicleList = new CompVehicleList();
portletVehicles.add(compVehicleList);
portletVehicles.setHeight(250);
//define a portlet for showing all countries
portletCountries = new Portlet();
portletCountries.setHeading("Länder");
configPanel(portletCountries);
portletCountries.setLayout(new FitLayout());
CompCountryList compCountryList = new CompCountryList();
portletCountries.add(compCountryList);
portletCountries.setHeight(250);
//add both Portlets to Portal
portal.add(portletUser, 0);
portal.add(portletVehicles, 1);
So first of all this works fine and looks great :-)
Now i have a a button in a accordeon menu. The Listener on this button should hide all portlets in the portal (at this time its the portletUser and portletVehicles) and then add another portlet (for example the portletCountries):
portletUser.hide();
portletVehicles.hide();
portal.add(portletCountries, 0)
Question from above again ;-)
Is it possible to make a kind of "clear-Portal" or "hide all portles" for a defined Portal?
Or have i always manually clear the portal like in my example code above?
What is the best practice for this functionallity?
Thanks all for your tips!
Lars.
I haven't used Ext-GWT -- but looking at the Javadoc for Portal there are two things I would try:
for (LayoutContainer c : portal.getItems()) {
c.hide();
}
or, more generally, wrap a Portal in your own class which records the Portlets which are in the Portal -- then you can get a List rather than List.

Categories

Resources