model,wicket,wicket-6,wicket-1.6
I don't know where CSRFSafeForm is coming from. But you can do the same with a standard Form and CompoundPropertyModel: IModel<User> userModel = new PropertyModel<>(user); Form<User> form = new Form<>("form", new CompoundPropertyModel<User>(user)); form.add(new TextField<>("name")); form.add(new TextField<>("address.city")); ...
Ok... I am SOOOOO stupid... My development system is windows... so it is not case sensitive, our live server is linux, which is... so the java class name had one uppercase letter that was lowercase in the html file name... Genius!...
You're adding the input field to the update call within the update method. This instructs Wicket to replace the input field, rendering the text field again. Thats why the cursor jumps to the first position. Why do you add the text field to the update? I don't see any imperative...
use FeedbackCollector as in example: new FeedbackMessagesModel(this) { @Override protected List<FeedbackMessage> collectMessages(Component panel, IFeedbackMessageFilter filter) { return new FeedbackCollector(YourComponent.this.getParent()) { @Override protected boolean shouldRecurseInto(Component component) { return true; // your citeria here } }.setIncludeSession(false).collect(filter); } }; ...
Option 1: Add an "onclick" AjaxEventBehavior to each item: new DataView<T>(id, dataProvider) { @Override protected void populateItem(Item<T> item) { item.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget target) { // This will execute when row is clicked } }); // Continue populating item here } } Option 2: If you don't...
java,ajax,listview,wicket,panel
What I would do, and really like, is to work with events. I define a global AjaxUpdateEvent like this: AjaxUpdateEvent public class AjaxUpdateEvent { public AjaxRequestTarget target; public AjaxUpdateEvent( AjaxRequestTarget target ) { this.target = target; } public AjaxRequestTarget getTarget() { return this.target; } } Then, I subclass events that...
java,javascript,html,css,wicket
In order to use Wicket to create HTML emails, we need to fake the request/response cycle. I wrote this convenient method that renders a bookmarkable page (pageclass + pageparameters) to a string: http://www.danwalmsley.com/render_a_wicket_page_to_a_string_for_html_email protected String renderPage(Class extends Page> pageClass, PageParameters pageParameters) { //get the servlet context WebApplication application = (WebApplication)...
I had the same problem once on a page with a very long database query. The query was expected to be long so the 1+ minute load time for that page was expected. But if I clicked to an other page, that page will load after the first one and...
Try using the actual request parameters instead: RequestCycle.get().getRequest().getQueryParameters() ...
I agree with @biziclop - do not use for this case. Possible options: 1. If "link" is an AjaxLink then make the second link a BookmarkablePageLink and update it too with the new value as a page parameter Make the second link a Link that uses `setResponsePage(NewPage.class, pageParametersWithValue) ...
The problem is in: List<Rezervace> rezervace = rezervaceDao.getAllRezervace(); ListView listview = new ListView("rezervaceList", rezervace) The list view initializes itself with a static list. It should instead ask the DB for new data on every refresh. Read https://cwiki.apache.org/confluence/display/WICKET/Working+with+Wicket+models#WorkingwithWicketmodels-DynamicModels about static vs. dynamic models....
since I can't update the listview via target.add(listview); I added a WebMarkupContainer like this: final WebMarkupContainer datacontainer = new WebMarkupContainer("data"); datacontainer.setOutputMarkupId(true); add(datacontainer); and now I can update the onClick method: target.add(datacontainer); this works fine - problem solved. but why replacing the children didn't work is still unclear to me...
My approach would be to make the <tr> a wicket component for example a WebMarkupContainer and attach to it an AjaxEventBehavior for the click event and there go to same same destination as <XXX>DetailLink points you. Example: private WebMarkupContainer tr() { WebMarkupContainer wmc = new WebMarkupContainer("tr"); wmc.add(new AjaxEventBehavior("click") { @Override...
javascript,jquery,css,internet-explorer-8,wicket
It worked after adding chain of events one in aonther: The follwing is the code which helps some body. $(document).ready(function(){ var el; $(".ie8DropdownFix").each(function() { el = $(this); el.data("origWidth", el.outerWidth()) ;// IE 8 can haz padding }).click(function(){ $(this).css("width", "auto"); }) .bind("blur change ", function(){ el = $(this); el.css("width", el.data("origWidth")); var el2;...
java,wicket,wicket-1.5,wicket-6
You have to use the add method: PageParameters pp = new PageParameters(); pp.add("mode",value); After that redirect as usual....
hibernate,serialization,blob,wicket
You can make the Blob transient and then it won't be serialized but it will be null upon deserialization: private transient Blob data; I think your only other option is to create a separate object for the blob and only reference it in the RawDataEntity and the use a LoadableDetachableModel...
Check your server logs for errors related to the serialization of the opener page. PageExpiredException means that the page cannot be found in the page storage. If there was an error with the serialization then it won't be stored and thus later won't be found too.
java,wicket,textfield,wicketstuff
Try with an AjaxEventBehavior("change") on your NumberField. For anything more serious you'll have to add the behavior to the wrapped numberInput.
java,wicket,java-6,wicket-6,modal-window
It is solved. It was a issue with one of the classes that wasn't serializable. Harm...
DropDownChoice#onSelectionChanged() is an empty hook method, you don't need to call it from your override.
Session.get().getFeedbackMessages() gives you the feedback messages in the session only - but since Wicket 6 feedback messages are stored along with their components: https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+6.0#MigrationtoWicket6.0-FeedbackStorageRefactoring...
Try with new FileUploadField("browseFile", new ListModel<FileUpload>(yourList));. It uses a List now so it is possible to use HTML5 <input type="file" multiple>, i.e. you can upload several files at once with modern browsers....
You need to use #setResponsePage(Page) instead, not #setResponsePage(Class). First you need to get a reference to the page with that id: session.getPageManager().getPage(pageId)....
You should use a CheckGroup with Checks instead: public ResultPage(PageParameters params) throws APIException { Form form = new Form("form"); CheckGroup selection = new CheckGroup("selection", new ArrayList()); selection.setRenderBodyOnly(false); form.add(selection); PageableListView view = new PageableListView("view", list, 10) { @Override public void onConfigure() { super.onConfigure(); setVisible(list.size() > 0); } @Override protected void populateItem(ListItem...
Submit.add(new PleaseWaitBehavior(new Model<String>( "Processing Message " + loadingNumber + " of " + size))); I hope you realize that here you concatenate a String that is used later in the UI. There is no code that will re-calculate this again and construct a new String for the UI. Please read...
spring,intellij-idea,jboss7.x,wicket,jrebel
Change the deployment artifact from 'war' to 'war exploded' did the job.
You should use composition instead of inheritance for such use cases. I.e. use a Panel that is created by a (protected) factory method. The child page should override this method and create a different Panel.
After searching on the web I found this: http://wicketinaction.com/2012/11/uploading-files-to-wicket-iresource/ So we need an extra line since Wicket 6.18.0: public UploadValuePage(PageParameters parameters) { super(parameters); Bytes maxSize = Bytes.kilobytes(20000); ServletWebRequest swr = (ServletWebRequest) getRequest(); MultipartServletWebRequest mswr = swr.newMultipartWebRequest(maxSize, "uploadId"); mswr.parseFileParts(); // since Wicket 6.18.0 FileItem item = mswr.getFile("fileInput").get(0); // process item }...
For the binary part, try something like this: final ResourceStreamRequestHandler target = new ResourceStreamRequestHandler(new AbstractResourceStream() { @Override public String getContentType() { return "application/octet-stream"; } @Override public InputStream getInputStream() throws ResourceStreamNotFoundException { return new ByteArrayInputStream(yourBinaryContent); } @Override public void close() throws IOException { } }); target.setFileName("response.dat"); target.setContentDisposition(ContentDisposition.ATTACHMENT);...
This is possible in Wicket 7.0.0-M1 - since https://issues.apache.org/jira/browse/WICKET-4994.
I think you should just use a AjaxSelfUpdatingTimerBehavior to implement your desired functionlality. In this case (because you are moving to another page), I think it is more appropriate to use its superclass: AbstractAjaxTimerBehavior Just add this to your Page / Panel add(new AbstractAjaxTimerBehavior(Duration.seconds(1)){ protected void onTimer(AjaxRequestTarget target) { //...
java,listview,wicket,dropdownchoice
I'm still a bit confused about what you are trying to achieve here, but I'll take a stab in the dark. If I understand correctly, you want to move away from DropDownChoice, as it has to be applied to a <select> tag, and change it into a ListView, as it...
java,wicket,wicket-1.6,wicket-6,wicketstuff
This is the documentation for Component.getMarkupId(). So you need access to the components to get MarkupId's and do what you want to do. /** * Retrieves id by which this component is represented within the markup. This is either the id * attribute set explicitly via a call to {@link...
java,asynchronous,websocket,wicket,cdi
Looks like http://wicket.apache.org/guide/guide/nativewebsockets.html#nativewebsockets_6 (the FAQ). WebSocket communication is not intercepted by Servlet Filters so DI frameworks like CDI, Spring and Guice have no chance to prepare their scoped beans. In your case RequestScoped. You can use only application and prototype scoped beans.
As an alternative: subclass TabbedPanel and provide your own custom markup.
You'll have to do some conversion. Either convert the list of choices: form.add(new DropDownChoice<Integer>("number", new AbstractReadOnlyModel<List<Integer>>() { public List<Integer> getObject() { return MyChoices.getAllAsInts(); } } ); or the selected choice: form.add(new DropDownChoice<MyChoices>("number", Arrays.asList(MyChoices.values()) { public IModel<?> initModel() { final IModel<Integer> model = (IModel<Integer>)super.initModel(); return new IModel<MyChoice>() { public MyChoice...
java,validation,wicket,custom-validators,wicket-1.6
Since your form has a selector giving a DimPeriod, you need to make a validator for that. Your validator class should be something like: public class DimPeriodValidator implements IValidator<DimPeriod> { @Override public void validate(IValidatable<DimPeriod> validatable) { //Validation logic here } } where I've skipped trying to actually write the validation....
You can create the dropdown and the textfield normally and just make them hidden initially. Then use the button clicked event handler to show the components via ajax.
java,internationalization,wicket
I ended up copying / modifying Wicket's private class MessageContainer (nested in org.apache.wicket.markup.resolver.WicketMessageResolver) like so: https://gist.github.com/totof3110/cf5f05731816a58d8597 Then I can have Java code like: final String messageKey; if (userLoggedIn) { messageKey = "logged.in"; } else { messageKey = "logged.out"; } MessageContainer message = new MessageContainer("message", messageKey); BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>("link",...
Store each temp file in a folder with the session id. Get the session id like this: Session.get().getId(); Each user will download their files from their own unique session folder so file names don't matter anymore. ...
I was unable to find lib with such data provider, so I've implemented one - its called IterableGridView Here is the code: https://github.com/maciejmiklas/cyclop/tree/master/cyclop-wicket-components Iterable Grid View is based on Wicket's GridView, however it does not work with IDataProvider but with IterableDataProvider. This new data provider relies only on plain java...
Yes, it is. Here's a simple example: Page: package com.mycompany; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.html.WebPage; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { super(parameters); Fragment fragment = new Fragment("fragment", "fragment-markup", this); fragment.add(new MyPanel("panel")); add(fragment); } } Page markup: <!DOCTYPE...
You should use the value of the first choice to determine the value of the second one. I this example I chose to use a AjaxFormComponentUpdatingBehavior that triggers the Ajax update and performs the value change. I'm providing the simple example of populating the second DropDownChoice with the Federal States...
java,eclipse,serialization,lambda,wicket
It's caused by this bug with the JDT compiler's handling of anonymous inner classes inside lamda expressions: "The problem here is that during generation of the deserialize lambda helper method the 'name' of the inner class containing the implementation lambda method is seen as $Local$ when we ought to be...
I'm pretty sure the problem is in your Mockito rule (the when): when(localizer.getString(eq("bla.bla.bla.offset"), (Component)anyObject(), anyString())).thenReturn("0"); It doesn't match the real call and thus later the value is null. Play in this area....
Question is answered in Wicket ModalWindow position I used this to give my modal window a new position....
Here is how the code should look really like: public class JobDetails extends Panel { private static final Logger LOGGER = Logger.getLogger(JobDetails.class); public static final long serialVersionUID = 42L; private List<Job> list; public JobDetails(String id, final PageParameters params) { super(id); FeedbackPanel feedbackpanel = new FeedbackPanel("feedbackpanel"); add(feedbackpanel); } @Override protected void...
Here are few possible reasons: MyPage fails to serialize Wicket stores stateful pages in page storage (in the disk, by default). Later when you click a stateful link Wicket tries to load the page. First it looks in the http session where the page is kept in its live form...
I think a nice Wicket-y solution combines stuff that is already in Michael's answer, with a Behavior, so you can just add this to your form. form.add( new ScrollToTopBehavior()); The behaviour itself would like something like this: public class ScrollToTopBehavior extends Behavior { @Override public void renderHead( Component component, IHeaderResponse...
java,html,selenium,xpath,wicket
Since "preceding-sibling" is so error-prone (it will break as soon as the HTML structure changes a little bit), here's a more stable variant (wrapped for legibility): //span[@id = 'excludeDepotCheckBox5']//input[ @id = //span[@id = 'excludeDepotCheckBox5']//label[normalize-space() = '001']/@for ] ...
java,wicket,wicket-1.5,wicket-6
ResourceStreamResource doesn't implement HttpServletResponse. You could use ResourceStreamResource#setCacheDuration(Duration.NONE) to disable caching. It will do the following for you: public void disableCaching() { this.setDateHeader("Date", Time.now()); this.setDateHeader("Expires", Time.START_OF_UNIX_TIME); this.setHeader("Pragma", "no-cache"); this.setHeader("Cache-Control", "no-cache, no-store"); } Is this what you are after?...
java,html,wicket,code-reuse,reusability
You can do this by creating an abstract class for a page with its own HTML file. Using the < wicket:child> tag you can add data specific to the subclass of the page with their own html file. You'd have to add the componts in the abstract class, not the...
Even if have CrossContext set to true, the ClassLoader of the calling class needs to have access to the class that it is trying to load. Try to deploy the jar(s) containing the classes to both web applications. quote from the tutorial: Solution-1: If we could externalize the custom data...
java,javascript,jquery,html,wicket
You have to send the current attribute value to the server as a 'dynamic extra parameter': link.add(new AjaxEventBehavior("click") { updateAjaxAttributes(ARA ara) { super.updateAttributes(ara); ara.getDynamicExtraParameters() .add("return {'q' : jQuery('#' + attrs.c).attr('testAttr') };"); } onEvent(ART art) { RequestCycle requestCycle = RequestCycle.get(); String val = requestCycle.getRequest() .getRequestParameters() .getParameterValue("q") .toString(); // ... } });...
arrays,hibernate,model-view-controller,wicket
You should use a Repeater to add your TextFields. For example a ListView ListView listview = new ListView("listview", list) { protected void populateItem(ListItem item) { item.add(new TextField("textField", item.getModel())); } }; With approriate HTML: <span wicket:id="listview"> <input wicket:id="textField" type="text"></input><br/> </span> To use multiple fields in each row, the easiest solution is...
You have to download from a resource, see http://wicketinaction.com/2012/11/uploading-files-to-wicket-iresource/ and read http://wicket.apache.org/guide/guide/resources.html
table,wicket,repeater,dynamic-data
You can use, for example, a ListView that draws a lot of DataTables. (side note:I think this will be not very fast, as you will generate loads of HTML. ) Java: List<DataVo> dataVoList = ... //create your list of datavo's add(new ListView<DataVo>("listview", dataVoList) { protected void populateItem(ListItem<DataVo> item) { DataVo...
This is what I came up with in the end. I subclassed IContextProvider<AjaxRequestTarget, Page> to create a custom provider for AjaxRequestTarget objects. When an AjaxRequestTarget is requested, I broadcast it to the component tree using Wicket's event mechanism. public class BroadcastingAjaxRequestTargetProvider implements IContextProvider<AjaxRequestTarget, Page> { private final IContextProvider<AjaxRequestTarget, Page> parent;...
You could either set the visibility of the entire ListView with setVisiible like this and implementing a custom method shouldListViewBeVisible(): PageableListView plv = new PageableListView() { @Override protected void populateItem(ListItem item) { //populate listitem } @Override protected void onConfigure() { setVisible(shouldListViewBeVisible()); } }; Or you could try to use the...
Look for the class FormComponent. You could do something like this: public class FeedbackTextField<T> extends FormComponent<T> { public FeedbackTextField(String id) { this(id, null); } public FeedbackTextField(String id, IModel<T> model) { super(id, model); TextField<T> tf = new TextField<T>("tx"); add(tf); add(new FeedbackPanel("fb").setFilter(new ComponentFeedbackMessageFilter(tf))); } } FormComponent works like a Panel so you...
You need to use "resource bundles". See http://wicket.apache.org/guide/guide/resources.html#resources_6. You can wrap the registrations with "if (usesDeploymentMode()) {...}"
Move the code snippet of JobDetails above from the constructor to #onInitialize() method. There it will be already added to its parent and it will be OK to replace it.
Here is some info on page versioning: http://wicket.apache.org/guide/guide/versioningCaching.html If you do not need support for back button, you can disable page versioning - it has not side effects, assuming that your pages handle back button correctly. Jumping back to the page that has no state can create page without initial...
You can "drill-up" the DOM hierarchy using the parentNode property. In your case, the TD is the grand-grand-parent element of the link (with a paragraph and a span in between) so what you need to add to your link would be something like this: onclick="javascript:this.parentNode.parentNode.parentNode.style.backgroundColor = '#009999';" Or in the...
Approach 1) requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(new PageProvider(page), RedirectPolicy.NEVER)) Use it instead of setResponsePage(Page/Class) Approach 2) Provide your own IPagerRenderer and never redirect for this specific page See Application#setPageRendererProvider. Extend from WebPageRenderer to save you some troubles....
You can use any JS/CSS solution and just integrate it with Wicket to send the Ajax call when the value changes. Here is one such JS solution: http://www.bootstrap-switch.org/
There are no other differences. The difference lies purely in the syntax. With IModel<?>, the casting has to be done explicitly (as you noted). However, by using generics, you tell the compiler to cast it to Bar when returning from the getObject() method, so you don't have to cast it...
spring,hibernate,tomcat,jetty,wicket
nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey This exception occurs of there are conflicting version of javax.persistence.ForeignKey class. Check your classpath and if you are using maven check the dependencies....
Style your inputs with CSS child selectors: div.metaCommentListStyle input { margin-left: 4px; } If you need more control over the markup use CheckGroup/Check instead....
Instead of using your User object I would suggest that you create a class that represents what you're going to filter and react upon those values in your IDataProvider. What currently happens is that you're using the User object to represent your FilterState and wicket tries to set the String...
You can use: dsChk.setDefaultModel(new PropertyModel(metaCommentTechSpeedBean, "dsChk")); Or take a look a CompoundPropertyModel Then you get something like this CompoundPropertyModel<MetaCommentTechSpeedBean> props = new CompoundPropertyModel<MetaCommentTechSpeedBean>(metaCommentTechSpeedBean); Form<MetaCommentTechSpeedBean> form = new Form<MetaCommentTechSpeedBean>("wicketid", props); CheckBox dsChk = new CheckBox("dsChk"); form.add(dsChk); add(form); The CompoundPropertyModel will set the correct PropertyModel...
java,properties,resources,wicket,resourcebundle
Solution: First, the answer of martin-g has given the right direktion. The properties-File have to be the same name like the Application-class ("WicketApplication.properties"). Second, very useful was to change the debuglevel in Wicket (src\main\resources\log4j2.xml) from LEVEL.INFO to LEVEL.DEBUG. There was a many Information about the URL (Path) which Wicket has...
When you do getNumberFormat() on the converter, it doesn't return a reference to the NumberFormat instance that the converter will use, but rather a clone of the instance: @Override public NumberFormat getNumberFormat(final Locale locale) { NumberFormat numberFormat = numberFormats.get(locale); if (numberFormat == null) { numberFormat = newNumberFormat(locale); setNumberFormat(locale, numberFormat); }...
You can move the renderHead() method to JGrowlBehavior. This way it will contribute the dependencies first and then jgrowl.js itself. If the dependencies are contributed by something else in the page too Wicket will detect this and contribute them just once. In Wicket 6.x there are further improvements in this...
When validation fails on a FormComponent, its rawInput isn't cleared - this is so that the user can fix the value, rather than having to enter everything from scratch. In your case you are basically changing the model behind the FormComponent's back so it doesn't know there is a new...
I found what is wrong. Actually, the page I am loading is fetching data from a DB and they happen to be old data that were even deleted in the DB.
javascript,html,internet-explorer,wicket,internet-explorer-10
I did fix the issue after some playing around. It turned out that, in the newer versions of IE userAgent is not same in every versions. The user agent in my IE10 does not contain "MSIE", and I was trying to split the userAgent by "MSIE", and it was resulting...
jquery,twitter-bootstrap,wicket
$("wicketExtensionsBreadCrumbBar") is broken selector because there is no HTML element with name wicketExtensionsBreadCrumbBar. You need either $(".wicketExtensionsBreadCrumbBar") for CSS class selection or $("#wicketExtensionsBreadCrumbBar") - selection by ID.
I found that I had to do setOutputMarkupPlaceholderTag(true) on both the resultContainer and the feedback. After that adding them to the requesttarget works as expected.
javascript,jquery,wicket,modal-window
For an unknown reason to me the ModalWindow is opened with JavaScript timeout of 0 seconds. So you need to execute your custom JavaScript again with a timeout, e.g.: target.appendJavaScript("setTimeout(function() {$('.wicket-modal').css('width', 888+'px');}, 10);"); ...
java,validation,error-handling,wicket,wicket-6
Read the docs for ValidationError, setMessage does only provide a fallback if the key added using addKey is not found. You can't have both at the same time. What you need to use is variable substitution by using setVariable(s) and use the variable keys in your properties file with the...