Implementing MixedParamUrlCodingStrategy prevents my site from using CSS - java

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.

Related

Wicket and Netbeans - some files are not openning

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.

How to use PDFBox to create a link that goes to *previous view*?

By using PDFBox, it is easy to create a link that goes a particular page or page view by using PDPageDestination. For example, the following code will make a link that goes to page 9:
PDAnnotationLink link = new PDAnnotationLink();
PDPageDestination destination = new PDPageFitWidthDestination();
PDActionGoTo action = new PDActionGoTo();
destination.setPage(document.getPage(9));
action.setDestination(destination);
link.setAction(action);
Problem:
Instead of going to a particular page, I would like to go to the previous view.
For example, suppose in a PDF file, each of P.1 and P.2 has a link that goes to P. 9. Now I would like to put on P. 9 a link that goes back to where the user started.
If the user started out at P.1 and clicked the link to P.9, he arrives at P.9. When he clicks the link on P. 9, he will go back to P.1, where he came from. But If he started out at P.2, then the link at P.9 will go back to P.2 instead.
Question: How do I achieve this with PDFBox?
FYI, with Adobe Acrobat, this can be achieved by adding an "execute a menu item" action to a link, and then choosing "Previous View" as the menu item, as shown in this screenshot:
Link to Acrobat screenshot
With the guidance of Tilman, I managed to solve my own problem.
I cannot find a PDAction subclass that gives me the capability to add a "named action", so I created my own subclass, "PDActionNamed":
class PDActionNamed extends PDAction {
public static final String SUB_TYPE = "Named";
public PDActionNamed() {
super();
setSubType( SUB_TYPE );
}
public void setN( String s ) {
action.setName( "N", s );
}
}
To use the subclass,
PDAnnotationLink link = new PDAnnotationLink();
PDActionNamed action = new PDActionNamed ();
action.setN("GoBack"); // this is one of Acrobat's default named action
link.setAction(action);
It seems to work even on non-Javascript-supported PDF readers (e.g. SumatraPDF).
What you're talking about is a viewer dependant action; I don't think there is a way to do this generically but there should be ways to do this in Adobe Acrobat / Adobe Reader.
One such way is to insert a link that triggers an Action. The action could be a Javascript action and the Javascript could be relatively simple as the Acrobat Javascript API contains an "app" method called "goBack".
So, insert a link as you're doing right now. Insert not a GoTo action but a Javascript action. And set the Javascript to: "app.goBack()".
This should work in Acrobat (they have a similar example with a button form field in the Acrobat Javascript API reference. The question is whether it will work in other viewers as well and thus whether it will fulfil your business case.

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.

Display Flash Banner in Hippo Cms Site

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.

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