wicket

Wicket: FileUploadField with ListView

荒凉一梦 提交于 2019-12-10 21:08:24
问题 I have a page that is used to upload several files. For each file, the user must specify a type and a description, that's why I can't use MultiFileUploadField ... so I use a RepeatingView with a FileUploadField in each element along with the other two fields I need. The problem is that whenever the "add File" button is clicked ( AjaxLink ), the FileUploadFields that already had a file, are reset to null... What can I do? Here is the ListView (sorry, it wasn't a RepeatingView but a ListView ):

How to access wicket session from Jersey-2 request filter?

一曲冷凌霜 提交于 2019-12-10 20:39:47
问题 In Jersey 1.x we accessed the Wicket session from a (Jersey) session attribute, as described here https://stackoverflow.com/a/15767824/1399659. In moving to Jersey 2.x it seems the proper pattern to use a ContainerRequestFilter, which also allows Spring bean injection as well. We have this working successfully by including <param-name>jersey.config.server.provider.packages</param-name> as an init-param to the ServletContainer and using the @Provider annotation on a ContainerRequestFilter

Wicket 6: Howto inject a javascript function via AbstractDefaultAjaxBehavior?

隐身守侯 提交于 2019-12-10 19:50:07
问题 I have a page that has a JavaScript file attached to it. The JavaScript has a function that, at the end should call a function that has been injected by Wicket through AbstractDefaultAjaxBehavior. The JavaScript looks like this: function updateAmount(amount){ // do some calculations on amount saveAmount(amount); } The injected function should look something like this: function saveAmount(amount){ Wicket.Ajax.post({ u: '${callbackUrl}', dep: function(){ return [{name:'amount','value':amount}];

Attempt to set model object on null model of component

蓝咒 提交于 2019-12-10 17:36:49
问题 I'm new to Wicket, but googling this problem didn't give me anything that made sense. So I'm hoping someone in SO can help. I have a SiteChoice object that extends Form, and a SiteList object that extends DropDownChoice. My SiteChoice class looks like: public class SiteChoice extends Form { public SiteChoice(String id) { super(id); addSiteDropDown(); } private void addSiteDropDown() { ArrayList<DomainObj> siteList = new ArrayList<DomainObj>(); // add objects to siteList ChoiceRenderer

How to handle exceptions thrown in Wicket custom model?

折月煮酒 提交于 2019-12-10 17:32:51
问题 I have a component with a custom model (extending the wicket standard Model class). My model loads the data from a database/web service when Wicket calls getObject() . This lookup can fail for several reasons. I'd like to handle this error by displaying a nice message on the web page with the component. What is the best way to do that? public class MyCustomModel extends Model { @Override public String getObject() { try { return Order.lookupOrderDataFromRemoteService(); } catch (Exception e) {

How do you password protect a page with Wicket?

余生颓废 提交于 2019-12-10 17:18:27
问题 I want to password protect a webpage in Wicket so the user may only access it if he/she has logged in. I'd also like the page to show the login page, and then after logging in the original page the user was trying to get to. How is this done with wicket? I've already created a login page and extended the session class. 回答1: The framework-supplied way is to provide an IAuthorizationStrategy instance for your application, e.g., by adding to your Application init() method: init() { ...

How to unit test a custom Wicket component

浪子不回头ぞ 提交于 2019-12-10 16:28:58
问题 Given this really simple Wicket component: public class ProductImage extends WebComponent { public ProductImage(String id, Product p) { super(id, new Model(p)); add(new AttributeModifier("src", true, new Model(p.getImage()))); } } How to unit test it using WicketTester? Do I need a page? 回答1: I haven't actually done that (I've only tested panels), but startComponent() seems to be the way to do it. Something like this: Product product = new Product(/* initialize product here */); ProductImage

How to add anchor in Wicket's setResponsePage()?

徘徊边缘 提交于 2019-12-10 15:53:59
问题 We need to redirect users that access a certain url to a Wicket page and scroll to a anchor in the page. E.g., the users link directly to http://.../target/url/123 . Afterwards, the 123 id is looked up from database. Subsequently, the user will be redirected to a different page based on if the entity was found or not. After the entity has been fetched the user should be redirected to http://.../another/url/123#element123 . How can we achieve this with Wicket? The page should also be

How to test AjaxEventBehavior(“onClick”) for Apache Wicket radio button?

天大地大妈咪最大 提交于 2019-12-10 15:26:37
问题 I'm using apache wicket and I run into trouble regarding testing the AjaxEventBehavior for a Radio button. Actually I want to test the "onClick" event like in my case when I select/click a radio button from a RadioGroup a specif page is rendered. Code snippet: RadioGroup<Boolean> selectPageRadioGroup = new RadioGroup<Boolean>("selectPageRadioGroup", new Model<Boolean>(Boolean.TRUE)); selectPageRadioGroup.setDefaultModel(new Model<Boolean>(Boolean.TRUE)); final Radio<Boolean> radioButton1 =

SetResponsePage in Wicket

核能气质少年 提交于 2019-12-10 14:47:17
问题 I saw that there are two ways to set a responsePage in Wicket's WebPage: setResponsePage(new MyPage()); or setResponsePage(MyPage.class); What are the differences between these two? 回答1: The first one will redirect to a bookmarkable URL. Please see also the Wicket FAQ. 回答2: Wicket's doc sais it best: "setResponsePage(new MyWebPage()) (or setResponsePage(new MyWebPage(myPageParameters))) can be used if you want to have a bookmarkable url in the browser (your page must have default constructor