Re: AJAX update and file download on Wicket 1.5
You can always redirect to an error page incase of exceptions / errors. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-update-and-file-download-on-Wicket-1-5-tp4095241p4666261.html Sent from the Users forum 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: AJAX update and file download on Wicket 1.5
So I modified my AjaxFileDownload init method to eliminate the abstraction of getResourceStream. Code as follows: AjaxFileDownload.java... Similar to AJAXDownload described in the Wiki https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html except for the following modifications: /** * Call this method to initiate the download. */ public void initiate(AjaxRequestTarget target, String fileName, InputStream is) { this.fileName = fileName; this.is = is; String url = getCallbackUrl().toString(); if (addAntiCache) { url = url + (url.contains(?) ? : ?); url = url + antiCache= + System.currentTimeMillis(); } // the timeout is needed to let Wicket release the channel target.appendJavaScript(setTimeout(\window.location.href=' + url + '\, 100);); } /** * Hook method providing the actual resource stream. */ protected IResourceStream getResourceStream() { return new AbstractResourceStreamWriter() { public void write(Response output) { WebResponse response = (WebResponse)output; byte[] buffer = new byte[256]; try { int read; while((read = is.read(buffer)) != -1) { response.write(buffer, 0, read); response.flush(); } response.close(); } catch (Exception e) { response.write(e.toString().getBytes()); response.close(); } getComponent().getRequestCycle().setResponsePage(MCEVToolPage.class); } }; } Implementation: final AjaxFileDownload fileDownload = new AjaxFileDownload(); AjaxLink fileDownloadLink = new AjaxLink(fileDownloadLink) { @Override public void onClick(AjaxRequestTarget target) { StringBuilder fileNameBuilder = new StringBuilder(); //Build filename . . StringBuilder dataBuilder = new StringBuilder(); //builder data to be included in the file .. .. fileDownload.initiate(target, fileNameBuilder.toString(), new ByteArrayInputStream(dataBuilder.toString().getBytes())); } } fileDownloadLink.add(fileDownload); add(fileDownloadLink); Now you can create a single instance of AjaxFileDownload and include that in your Application file and request when ever needed. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-update-and-file-download-on-Wicket-1-5-tp4095241p4657667.html Sent from the Users forum 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: Label not updating on AJaxButton submit
Martin, Would you be kind enough to give an example? I tried the following: ajaxSimpleUploadForm.add(new AjaxButton(uploadVideoSubmit) { @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { AbstractResourceStreamWriter writer = new AbstractResourceStreamWriter() { @Override public void write(Response output) { for(FileUpload upload : uploads) { System.out.println(new Date() + : + Start Reading); try { long size = upload.getSize(); BufferedReader fileReader = new BufferedReader(new InputStreamReader(upload.getInputStream())); ByteArrayOutputStream os = new ByteArrayOutputStream(); int i; int counter = 0; while((i = fileReader.read()) != -1) { counter ++; os.write(i); if(counter == 100) { long osSize = os.size(); int p = Float.valueOf((100 * osSize) / size).intValue(); counter = 0; if(p percent) { percent = p; p = 0; } } } os.flush(); os.close(); System.out.println(new Date() + : + File read successfully); } catch(IOException ie) { VideoUploadPanel.this.error(There was a problem uploading the file); } } } }; getRequestCycle().scheduleRequestHandlerAfterCurrent( new ResourceStreamRequestHandler(writer); ... } The progress bar still does't get updated. Here is the response.. Note the delay of 8 seconds marked in bold? Thats when the file is getting uploaded. Tue Jan 17 02:21:38 EST 2012: Loading value.. Tue Jan 17 02:21:39 EST 2012: Updating Component Tue Jan 17 02:21:39 EST 2012: Loading value.. Tue Jan 17 02:21:40 EST 2012: Updating Component Tue Jan 17 *02:21:40 EST 2012*: Loading value.. Tue Jan 17 02:21:43 EST 2012: Start Reading Tue Jan 17 02:21:48 EST 2012: File read successfully Tue Jan 17 *02:21:48 EST 2012*: Updating Component Tue Jan 17 02:21:48 EST 2012: Loading value.. Tue Jan 17 02:21:50 EST 2012: Updating Component Tue Jan 17 02:21:50 EST 2012: Loading value.. Tue Jan 17 02:21:51 EST 2012: Updating Component Tue Jan 17 02:21:51 EST 2012: Loading value.. Tue Jan 17 02:21:52 EST 2012: Updating Component Any help / example would really be a life saver. I couldnt find much example online on IResource and AjaxChannel -Milton Martin Grigorov-4 wrote Hi, I think the Ajax calls are serialized. The page instance can be used by a single request at any time. So you submit the form and this request acquires the lock on the page. AjaxSelfTimerUpdatingBehavior cannot use the page until the first request unlock it. Additionally the Ajax calls are serialized at the client side (JavaScript). See AjaxChannel class for more information about this. To be able to do what you want I suggest to use IResource to upload to. This way there wont be lock on the server side and with AjaxChannels with different names at the client side you will solve both problems. On Mon, Jan 16, 2012 at 2:51 AM, malebu lt;milton.quranda@gt; wrote: I have a requirement where i have to upload a video from a page and show the upload progress when the upload is 100% complete need to update the progress label as processing video. I decided to go with a simple outer div and internal div while update the internal div percentage to show the progress. Finally i added a Label inside the internal div to show the status... /div style=border: 1px solid #5d4617; padding: 3px; background-color: #191B10; div style=width:400px; background-color: #55; color: white; font-size: 8px; align=left div style=width:0%; background-color: #FF9900; align=right wicket:id=customProgressLoading.../div /div /div/ Finally i added AjaxSelfUpdatingTimerBehavior to the internal div to fetch the progress and label every 2 seconds. When i click on submit button.. the label is not update while the form is being submitted. it shows the final progress i.e. 100% and processing completed after file is uploaded. I am using AjaxButton
Re: Wicket spring security sample app
Here is how i did it... *created a spring-config application-security.xml* /http create-session=ifRequired auto-config=true remember-me/ intercept-url pattern=/** access=IS_AUTHENTICATED_ANONYMOUSLY / /http authentication-manager alias=authenticationManager authentication-provider user-service-ref=userDetailsService/ /authentication-manager global-method-security secured-annotations=enabled / / *in web.xml add the following lines:* / filter filter-namespringSecurityFilterChain/filter-name filter-classorg.springframework.web.filter.DelegatingFilterProxy/filter-class /filter filter-mapping filter-namespringSecurityFilterChain/filter-name url-pattern/*/url-pattern /filter-mapping / *in spring-config.xml* / bean id=userDetailsService class=org.springframework.aop.framework.ProxyFactoryBean property name=proxyInterfaces value=security.service.UserDetailsService/ property name=target bean class=security.service.UserDetailsServiceImpl property name=userDao ref=userDetailDao/ /bean /property /bean bean id=userDetailsService class=org.springframework.aop.framework.ProxyFactoryBean property name=proxyInterfaces value=security.service.UserDetailsService/ property name=target bean class=security.service.impl.UserDetailsServiceImpl property name=userDao ref=userDetailDao/ /bean /property /bean / *Add following annotation on pages you want to secure:* /@AuthorizeInstantiation(ROLE_ADMIN)/ // for users replace ROLE_ADMIN with USER_ROLE Create a UserDetailsService class: /public interface UserDetailsService extends org.springframework.security.core.userdetails.UserDetailsService { public void RegisterUser(UserDetail userDetail); public UserDetail loadUserByEmail(String emailAddress); public void deleteUserVerification(UserVerification userVerification); public void deleteUser(UserDetail userDetail); public void verifyUser(UserDetail userDetail); public UserDetail getByUsername(String username); }/ *Create UserDetailServiceImpl class:* /public class UserDetailsServiceImpl implements UserDetailsService { private UserDetailDAO userDao; @Override public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException, DataAccessException { return userDao.getUserDetail(s); } @Override public UserDetail loadUserByEmail(String emailAddress) { return userDao.getUserByEmail(emailAddress); } @Override public void deleteUserVerification(UserVerification userVerification) { userDao.deleteUserVerification(userVerification); } public UserDetailDAO getUserDao() { return userDao; } public void setUserDao(UserDetailDAO userDao) { this.userDao = userDao; } public void RegisterUser(UserDetail userDetail) { userDao.saveUserDetail(userDetail); } public void deleteUser(UserDetail userDetail) { userDao.deleteUserDetail(userDetail); } public void verifyUser(UserDetail userDetail) { userDetail.setEnabled(true); userDetail.setLocked(false); userDetail.setCredentialsExpired(false); userDetail.setExpired(false); userDetail.setAccountStatus(UserAccountStatus.VERIFIED); ListUserVerification userVerificationList = userDetail.getUserVerification(); UserVerification userVerification = userVerificationList.get(0); userDetail.getUserVerification().remove(0); userDao.updateUserDetail(userDetail); userDao.deleteUserVerification(userVerification); } public UserDetail getUser(String username) { return userDao.getByUsername(username); } @Override public UserDetail getByUsername(String username) { return userDao.getByUsername(username); } }/ *Create class UserVerification:* /@Entity @Table(name = userverification, uniqueConstraints = {@UniqueConstraint(columnNames = {userid})} ) public class UserVerification extends BasicEntity implements Serializable { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = userid, referencedColumnName = id, insertable = true, nullable = false, updatable = true) private UserDetail userDetail; private String verificationCode; public UserVerification() { } public UserVerification(String verificationCode) { this.verificationCode = verificationCode; } public UserVerification(UserDetail userDetail, String verificationCode) { this.userDetail = userDetail; this.verificationCode = verificationCode; } public UserDetail getUserDetail() { return userDetail; } public void setUserDetail(UserDetail userDetail) { this.userDetail = userDetail; } public String
Re: Can I modify the style of an option tag?
Refer http://wicket.apache.org/apidocs/1.4/org/apache/wicket/extensions/markup/html/form/select/Select.html then add the following code: option.add(AttributeModifier.replace(style,background-image: url(/images/icons/bug.gif))); thats should do the trick -Milton -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-I-modify-the-style-of-an-option-tag-tp4297927p4298256.html Sent from the Users forum 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
Label not updating on AJaxButton submit
I have a requirement where i have to upload a video from a page and show the upload progress when the upload is 100% complete need to update the progress label as processing video. I decided to go with a simple outer div and internal div while update the internal div percentage to show the progress. Finally i added a Label inside the internal div to show the status... /div style=border: 1px solid #5d4617; padding: 3px; background-color: #191B10; div style=width:400px; background-color: #55; color: white; font-size: 8px; align=left div style=width:0%; background-color: #FF9900; align=right wicket:id=customProgressLoading.../div /div /div/ Finally i added AjaxSelfUpdatingTimerBehavior to the internal div to fetch the progress and label every 2 seconds. When i click on submit button.. the label is not update while the form is being submitted. it shows the final progress i.e. 100% and processing completed after file is uploaded. I am using AjaxButton to upload on Ajax. Any idea how i can achieve this? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Label-not-updating-on-AJaxButton-submit-tp4298302p4298302.html Sent from the Users forum 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: Create Datatable with empty columns and rows
GridView seems more logical. I will give it a try but what about the vertical line between grids! ? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Create-Datatable-with-empty-columns-and-rows-tp3523546p3524463.html Sent from the Users forum 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
Create Datatable with empty columns and rows
http://apache-wicket.1842946.n4.nabble.com/file/n3523546/Screen_shot_2011-05-14_at_9.55.31_PM.png I need to create a table like the attached image. I am not seasoned in wicket. I am not able to analyze where to start. I was able to create a DataTable but could not figure out how to get it started. I get a list of category heads from a table as an object in list i.e. ListCategoryType types = db.getCategoryTypes(); I need to iterate through the list and populate the table with empty column with vertical line background and empty rows after each category display. Any help would be really appreciated. I am currently stuck at this. The code is as follows: html xmlns=http://www.w3.org/1999/xhtml; head /head body table width=100% border=0 cellspacing=3 cellpadding=0 id=category tr td width=296 align=center Category 1 /td td width=23 rowspan=8 align=center background=images/vertical_line_black.pngnbsp;/td td width=374 align=center Category 3 /td td width=27 rowspan=8 align=center background=images/vertical_line_black.pngnbsp;/td td width=515 align=center Category 5 /td /tr tr td align=centerSub category 1/td td align=centerSub category 1/td td align=centerSub category 1/td /tr tr td align=centerSub category 2/td td align=centerSub category 2/td td align=centerSub category 2/td /tr tr td align=centernbsp;/td td align=centernbsp;/td td align=centernbsp;/td /tr tr td align=center Category 2 /td td align=center Category 4 /td td align=center Category 6 /td /tr tr td align=centerSub category 1/td td align=centerSub category 1/td td align=centerSub category 1/td /tr tr td align=centerSub category 2/td td align=centerSub category 2/td td align=centerSub category 2/td /tr tr td align=centernbsp;/td td align=centernbsp;/td td align=centernbsp;/td /tr /table /body /html - -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Create-Datatable-with-empty-columns-and-rows-tp3523546p3523546.html Sent from the Users forum 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