MultiFileUploadField: Filter file types
Hello there. I'm am developing a web application where is possible to the user upload some photos. I would like to filter the files the user can choose. the user can choose up to 10 photos, but if some file is not a photo, i don't want to loose all the files, once after the submit, all the files selected are lost. Thank you ever one -- Marco Santos
DropDownChoices: How to force a selection.
Hello There. Im creating a page where the user can either create or update a registry. I have a few DropDownChoices, and i am trying, on the case o updating a registry, to set the a specific value of the choices of the dropdownchoice. Does any one know how? I have tryed to set a value on the PropertyModel that i use on the creation of the DDC. Here is the creation of the DDC: private void buildDistritosComboBox() { DistritosModel distritosModel = new DistritosModel(); SelectedChoice selectedDistrito = new SelectedChoice();//A class with a variable selectedChoice and it getter and setter DropDownChoice distritosDDC = new DropDownChoice(distritos, new PropertyModel(selectedDistrito, selectedChoice), distritosModel); distritosDDC.setOutputMarkupId(true); distritosDDC.setRequired(true); } Thanks a lot -- Marco Santos
Re: CompoundPropertyModel and Combobox
Thanx for the tip. It work on some cases. I found a pattern. For instance, if a component (be it a textfield or a DropDownChoice) has it self a Model, for instance a PropertyModel, the instance variables of the class that is used on the form model (CompoundPropertyModel) are not filled. EXAMPLE the form: public class ImovelHabitacionalForm extends Form { nbsp;nbsp;nbsp;nbsp;private final ImovelHabitacionalInput imovelHabitacionalInput = new ImovelHabitacionalInput(); nbsp;nbsp;nbsp;nbsp;... nbsp;nbsp;nbsp;nbsp;public ImovelHabitacionalForm() { nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;super(ID); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;setModel(new CompoundPropertyModel(imovelHabitacionalInput)); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;buildForm(); nbsp;nbsp;nbsp;nbsp;} nbsp;nbsp;nbsp;nbsp;/*The components creations */ nbsp;nbsp;nbsp;nbsp;private void buildForm() { nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*TRANSACTION TYPES*/ nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;List transactionTypes = TipoTransaccaoFacade.getTipoTransaccoes(); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;transactionType = new DropDownChoice(transactionType, transactionTypes); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*DISTRICTS*/ nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;DistritosModel distritosModel = new DistritosModel(); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;selectedDistrito = new SelectedChoice(); /*class with a instance variable selectedChoice and getter and setter*/ nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;distritosDDC = new DropDownChoice(distritos, new PropertyModel(selectedDistrito, selectedChoice), distritosModel); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*PRICE*/ nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;priceTextField = new TextField(price); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*AREA*/ nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/*Class with a variable name area and a getter and a setter*/ nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;private TextFieldAreaModel areaModel = new TextFieldAreaModel(); nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;areaTextField = new TextField(area, new PropertyModel(areaModel, area)); nbsp;nbsp;nbsp;nbsp;} } /*Part of the user input class used on the form model*/ private class ImovelHabitacionalInput implements IClusterable { nbsp;nbsp;nbsp;nbsp;private String district= ; nbsp;nbsp;nbsp;nbsp;private String transactionType= ; nbsp;nbsp;nbsp;nbsp;private String price= ; nbsp;nbsp;nbsp;nbsp;private String area = ; nbsp;nbsp;nbsp;nbsp;/*GETTERS AND SETTERS*/ } When the form is submited happens that the transactionType and the price variables on the class ImovelHabitacionalInput are filled with the values inserted by the user, but the district and the area dont. the diferences between the textfields and the dropdownchoices is that the transactionType and the price doesn't have a model itself. Does any one knows why if a model is supllyed to a form model, the respective instance variables are not filled, even more, those getters and setters are not called (in debug mode i noticed that too). Thanks a lot everyone MARCO SANTOS Marcin Palka wrote: The code below works just fine for me. Instead of using complex type as a model object for a drop down I use an instance of IChoiceRenderer to control what's used for an id and what's displayed as a value. User user = ; setModel(new CompoundPropertyModel(user)); add(new DropDownChoice(usrRole, SystemRole.asStringList(), new IChoiceRenderer() { @Override public String getDisplayValue(Object object) { return Enum.valueOf(SystemRole.class, object.toString()).getRoleName(); } @Override public String getIdValue(Object object, int index) { if (index == -1) { return SystemRole.SALESMAN.toString(); } return SystemRole.asStringList().get(index); } }).setRequired(true)); The combo items are populated from Enum values: public enum SystemRole { SYS_ADMIN(Administrator systemu), SERVICEMAN(Serwisant), NETWORK_ADMIN(Administrator sieci), SALESMAN(Pracownik punktu), ANY(Bez roli); private final String roleName; SystemRole(String roleName) { this.roleName = roleName; } public String getRoleName() { return roleName; } private static List stringList; public static List asStringList() { if (stringList == null) { stringList = new ArrayList(); for (SystemRole sr : values()) { stringList.add(sr.toString()); } } return stringList; } } And this is how model object looks like: public class User { private Integer usrId; private String usrLogin
MultiFileUploadField: How to filter file types
Hello there. Im using the MultiFileUploadField but i would like that the user could just see/choose some type of files. for instance, he could only select jpeg or/and png files. I notice that is possible to specify the max size of a file. Is possible to specify the type files that the user can select? Thanks a lot -- Marco Santos
Re: MultiFileUploadField: How to filter file types
I already thought about that, but like it implicates to change the original javascript file, i was trying not to do it, but i already changed it a little bit, i guess it would not make worse to change more a little bit. I changed it to short the name of the selected file from the path to just the name of the file. Thanx a lot igor.vaynberg wrote: even max size is checked serverside, you may be able to do the same for file types. alternatively you can hook in with a javascript by adding an onchange event and possibly rejecting a file. -igor On Tue, May 26, 2009 at 3:46 AM, Marco Santos mpssan...@gmail.com wrote: Hello there. Im using the MultiFileUploadField but i would like that the user could just see/choose some type of files. for instance, he could only select jpeg or/and png files. I notice that is possible to specify the max size of a file. Is possible to specify the type files that the user can select? Thanks a lot -- Marco Santos - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/MultiFileUploadField%3A-How-to-filter-file-types-tp23720718p23733477.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
CompoundPropertyModel and Combobox
Hello there. Im trying to submit a form, a simple one, that have some textfields, checkboxes and some comboboxes (DropDownChoice class). The model of the form is the CompoundPropertyModel which is setted like this: setModel(new CompoundPropertyModel(userInput)); The userInput is an instance of a class that have getters and setters which the names are the id's of the fields. When i submit the form, every field is filled with the user input information except the fields to the comboboxes which are empty. The dropdownchoices are instanciated like this: = JAVA CODE = selectedDistrito = new SelectedChoice(); distritos = new DropDownChoice(distritos, new PropertyModel(selectedDistrito, selectedChoice), distritosModel); = THE SELECTED CHOICE CLASS = public class SelectedChoice implements Serializable{ private String selectedChoice = null; /** Creates a new instance of SelectedChoice */ public SelectedChoice() { } public String getSelectedChoice() { return selectedChoice; } public void setSelectedChoice(String selectedChoice) { this.selectedChoice = selectedChoice; } } = END OF JAVA CODE = How can i in the CompoundPropertyModel fill the instance variables concerned to the dropdownchoices? Thank you very much -- Marco Santos
Re: What's the simplest way to do Context-sensitive Authorization in Wicket?
On the book Wicket in Action there is a chapter (12) that cover the Authentication and the Authorization. It will be very useful to you, and is very easy to understand and implement. This book is very good and i advise you to have, so you can consult as you need. Marco Santos Ben Hutchison-2 wrote: Hi all, I am tech leading our first Wicket project, and I and my co-workers are new to Wicket, but we have been having a good experience in the first few weeks. We have come across an challenge relating to security authorization that I would appreciate some advice regarding. Here are the simple business rules: - Site Users can create Listings - Users can View someone else's Listing - Users can Edit their own listing. So the authorization decision needs to examine some context (ie the Listing), as well as the current user, to determine whether they have an Edit or View role. A look at wicket-auth-roles suggested that it did not cater for context-sensitive roles of this kind? Ie IRoleCheckingStrategy.hasAnyRole(Roles roles) doesn't allow for any context parameters on which the strategy might make the decision. What is the simplest way to address my challenge? -Ben -- *Ben Hutchison Senior Developer * Level 2 476 St Kilda Road Melbourne VIC 3004 T 613 8807 5252 | F 613 8807 5203 | M 0423 879 534 | www.ibsglobalweb.com http://www.ibsglobalweb.com/ - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/What%27s-the-simplest-way-to-do-Context-sensitive-Authorization-in-Wicket--tp23733965p23734099.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
!! Wicket Authorization Problem !!
Hello there. I'm having problems developing Authorization on my webapplication. I have followed the steps of the chapter 12 of Wicket in Action. When i try to access to a protected page, the page is renderend instead of redirected to the Login page. Here is my code. I was wondering if anyone knows what am i missing. --Application Base class public class NetCasasApplication extends WebApplication{ public NetCasasApplication() { addComponentInstantiationListener(new IComponentInstantiationListener() { public void onInstantiation(Component component) { if(!getSecuritySettings().getAuthorizationStrategy().isInstantiationAuthorized(component.getClass())) { getSecuritySettings().getUnauthorizedComponentInstantiationListener().onUnauthorizedInstantiation(component); } } }); } @Override public Class getHomePage() { return Index.class; } @Override public Session newSession(Request request, Response response) { return new NetCasasSession(request); } } -- The Protected page (NetCasas extends WebPage) each page that is suppose to protected extends this class package pt.msoftware.netcasas.wicket.security; import pt.msoftware.netcasas.wicket.NetCasasBasePage; public class ProtectedPage extends NetCasasBasePage { } --The AuthorizationStrategy public class NetCasasAuthorizationStrategy implements IAuthorizationStrategy, IUnauthorizedComponentInstantiationListener { public boolean isInstantiationAuthorized(Class componentClass) { if(ProtectedPage.class.isAssignableFrom(componentClass)) { return NetCasasSession.get().isAuthenticated(); } return true; } public boolean isActionAuthorized(Component component, Action action) { throw new UnsupportedOperationException(Not supported yet.); } public void onUnauthorizedInstantiation(Component component) { throw new RestartResponseAtInterceptPageException(Login.class); } } On the constructor of the Application Base class (NetCasasApplication) an interceptor is registered. when i try to access a protected page, the method onInstantiation is executed. Inside the call getSecuritySettings().getAuthorizationStrategy() always return a IAuthorizationStrategy, never a NetCasasAuthorizationStrategy. So the method NetCasasAuthorizationStrategy.isInstantiationAuthorized is never executed. So i guess something is missing. Someone knows what? Thanks for the help. Os meus melhores cumprimenstos / Best Regards Marco Santos -- View this message in context: http://www.nabble.com/%21%21-Wicket-Authorization-Problem-%21%21-tp22318987p22318987.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: !! Wicket Authorization Problem !!
I already discovery what was wrong. Thanks anyway. on the Application Base class the AuthorizationStrategy and UnauthorizedComponentInstantiationListener must be registred like this: @Override protected void init() { NetCasasAuthorizationStrategy authorizationStrategy = new NetCasasAuthorizationStrategy(); getSecuritySettings().setAuthorizationStrategy(authorizationStrategy); getSecuritySettings().setUnauthorizedComponentInstantiationListener(authorizationStrategy); } Once again, thanks -- View this message in context: http://www.nabble.com/%21%21-Wicket-Authorization-Problem-%21%21-tp22318987p22320534.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Problems Refreshin a Image from AjaxLink
Hello there! I'm with problems refreshing an Image. On my web application i'm trying to refresh or change an Image that is on a Panel. On the panel there is a Image (it is rendered the first time) and a label. Outside the panel i have AjaxLink's (that are images too) that refresh the panel, and consequently the components on it, the image and the label. when the link is clicked, the label e refreshed with the new text, but the image still the same. The code is the following: /** *The Panel with the image to be refreshed: *(the label on the panel is freshed when the link is pressed. **/ public class PhotoPanel extends Panel { /** Creates a new instance of PhotoPanel*/ public PhotoPanel(String id, byte[] photoData, int size, Integer index) { super(id); setOutputMarkupId(true); MyImage mainPhoto = new MyImage(mainPhoto, photoData, size);//component that extends Image mainPhoto.setOutputMarkupId(true); Label label = new Label(index, MYLABEL: + index.toString()); add(mainPhoto); add(label); } } /** * The AjaxLink's on a Parent panel that holds a panel with the links, and the panel with the image * to be refreshed **/ private class PhotoSlideLink extends AjaxLink { private byte[] photoSlideData = null; Integer index = 0; public PhotoSlideLink(String id, byte[] photoSlideData ) { super(id); this.photoSlideData = photoSlideData ; MyImage photoSlide = new MyImage(photoSlide, photoSlideData , 100); add(photoSlide ); } @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { Panel newMainPhotoPanel = new PhotoPanel(mainPhotoPanel, photoSlideData , MAIN_PHOTO_SIZE, index++); newMainPhotoPanel .setOutputMarkupId(true); /*the first PhotoPanel created when the page was loaded*/ mainPhotoPanel.replaceWith(newMainPhotoPanel); mainPhotoPanel= newMainPhotoPanel ; ajaxRequestTarget.addComponent(newMainPhotoPanel); } } Does any one know why refreshing the panel, the label change, but not the image? Am i forgetting to do something? Thanks a lot -- View this message in context: http://www.nabble.com/Problems-Refreshin-a-Image-from-AjaxLink-tp14472713p14472713.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems Refreshin a Image from AjaxLink
Thanks a lot! I worked! Tell me, do you know a good book about wicket? I have red the 1st chapter o Wicket in Action from manning and it seams nice, but it is not finished yet. Thanks again! --ms Matej Knopp-2 wrote: Image doesn't change because it's being cached by the browser. To ensure that browser doesn't cache the image you need to append a string to url that changes on every refresh. Just like NonCachingImage does. -Matej On Dec 22, 2007 8:53 PM, Marco Santos [EMAIL PROTECTED] wrote: Hello there! I'm with problems refreshing an Image. On my web application i'm trying to refresh or change an Image that is on a Panel. On the panel there is a Image (it is rendered the first time) and a label. Outside the panel i have AjaxLink's (that are images too) that refresh the panel, and consequently the components on it, the image and the label. when the link is clicked, the label e refreshed with the new text, but the image still the same. The code is the following: /** *The Panel with the image to be refreshed: *(the label on the panel is freshed when the link is pressed. **/ public class PhotoPanel extends Panel { /** Creates a new instance of PhotoPanel*/ public PhotoPanel(String id, byte[] photoData, int size, Integer index) { super(id); setOutputMarkupId(true); MyImage mainPhoto = new MyImage(mainPhoto, photoData, size);//component that extends Image mainPhoto.setOutputMarkupId(true); Label label = new Label(index, MYLABEL: + index.toString()); add(mainPhoto); add(label); } } /** * The AjaxLink's on a Parent panel that holds a panel with the links, and the panel with the image * to be refreshed **/ private class PhotoSlideLink extends AjaxLink { private byte[] photoSlideData = null; Integer index = 0; public PhotoSlideLink(String id, byte[] photoSlideData ) { super(id); this.photoSlideData = photoSlideData ; MyImage photoSlide = new MyImage(photoSlide, photoSlideData , 100); add(photoSlide ); } @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { Panel newMainPhotoPanel = new PhotoPanel(mainPhotoPanel, photoSlideData , MAIN_PHOTO_SIZE, index++); newMainPhotoPanel .setOutputMarkupId(true); /*the first PhotoPanel created when the page was loaded*/ mainPhotoPanel.replaceWith(newMainPhotoPanel); mainPhotoPanel= newMainPhotoPanel ; ajaxRequestTarget.addComponent(newMainPhotoPanel); } } Does any one know why refreshing the panel, the label change, but not the image? Am i forgetting to do something? Thanks a lot -- View this message in context: http://www.nabble.com/Problems-Refreshin-a-Image-from-AjaxLink-tp14472713p14472713.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Problems-Refreshin-a-Image-from-AjaxLink-tp14472713p14473189.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]