PrimeFaces with multiple p:fileUpload tags on one page -- only the last tag works - file-upload

I use PrimeFaces 3.0-SNAPSHOT with JBoss AS7. I put three <p:fileUpload> tags in one form with option auto=true.
The problem is that to upload files I have to start with the last form and then upload to prelast and finally to the first one. Otherwise nothing is sent to the server (there is nothing to watch in FireBug JS console nor in Net console). Do you know how to resolve it? Uploading multiple files using one component is not usable for me.
EDIT: Forms are like:
<p:fileUpload id="videoThumbnail"
fileUploadListener="#{videoWrapper.handleImageUpload}"
update="#{#form}" process="#{#all}" auto="true" showButtons="false"/>
And videoWrapper.handleImageUpload is a typical PrimeFaces uploading handler. I don't enclose it, because I think it's not a problem. Requests are not sent to the server, so java server side seems to be unrelated.

I got an answer on PrimeFaces forum: http://forum.primefaces.org/viewtopic.php?f=3&t=16917&p=52525. Now this situation is not supported, maybe it will change in the future.

Related

Automate a button click on chrome://extensions page using selenium webdriver

I'm trying to write an automated test that will automate the process of updating a google chrome extension. I'm not aware of another method of doing this automatically so here is what I'm currently trying to do:
Open the chrome extensions page (as far as I'm aware this is just an html page unless I'm missing something).
Click on the "Update extensions" button
Here is what I have tried having opened the chrome extensions page:
IwebElement UpdateButton = driver.findelement(By.Id("update-extensions-now"));
UpdateButton.Click();
For some reason the button click is not registering. I have tried some other locators such as CSS path and Xpath but they don't work either. Also, when I debug this test, it passes fine so I know it's not an issue with any of my locators. I have (as a test) tried to automate clicks on the other elements on this page and it's the same issue. I can't get a handle on any elements on the chrome://extensions page at all.
Has anyone encountered this or have any ideas as to what's going on?
You can use the Chrome extensions API to auto-update required extension.
Find the file "manifest.json" in the default Google Chrome
C:\Users\*UserName*\AppData\Local\Google\Chrome\User Data\Default\Extensions
There find the update URL of your extension:
{
"name": "My extension",
...
"update_url": "http://myhost.com/mytestextension/updates.xml",
...
}
The returned XML by the Google server looks like:
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='yourAppID'>
<updatecheck codebase='http://myhost.com/mytestextension/mte_v2.crx' version='2.0' />
</app>
</gupdate>
appid
The extension or app ID, generated based on a hash of the public key, as described in Packaging. You can find the ID of an extension or Chrome App by going to the Extensions page (chrome://extensions).
codebase
A URL to the .crx file.
version
Used by the client to determine whether it should download the .crx file specified by codebase. It should match the value of "version" in the .crx file's manifest.json file.
The update manifest XML file may contain information about multiple extensions by including multiple elements.
Another option is to use the --extensions-update-frequency command-line flag to set a more frequent interval in seconds. For example, to make checks run every 45 seconds, run Google Chrome like this:
chrome.exe --extensions-update-frequency=45
Note that this affects checks for all installed extensions and apps, so consider the bandwidth and server load implications of this. You may want to temporarily uninstall all but the one you are testing with, and should not run with this option turned on during normal browser usage.
The request to update each individual extension would be:
http://test.com/extension_updates.php?x=id%3DyourAppID%26v%3D1.1
You can find even more detailed information on exntesions developers site: https://developer.chrome.com/extensions
If you look at the HTML of the "chrome://extensions" page you will notice that the "Update extensions now" button is contained within an iframe. You need to switch to the iframe before trying to register a button click. i.e:
(This is in c#. Note that this code is written from memory so it may not be 100% accurate. Also, you will want to write more robust method. This code just quickly demonstrates that by switching to the iframe, it will work ok)
String ChromeExtensionsPage = "chrome://extensions";
driver.Navigate().GoToUrl(ChromeExtensionsPage);
driver.Switchto().Frame("DesiredFrame");
IwebElement UpdateButton = driver.findelement(By.Id("DesiredButtonID"));
UpdateButton.Click();

JSF form with file upload and multiple select capabilities

I am using JSF 2.0, and I have a form with a primefaces autoComplete (multiple) field, and a couple of file inputs. Since I'm using a file input, my h:form tag uses enctype="multipart/form-data" .
However, when I set my form to be multipart, my autocomplete field only returns the last item to my bean (the list is always of size 1). This issue also occurs when just using a regular multiple select element instead of the primefaces autocomplete (the autocomplete makes use of a hidden multiple select element). When I remove enctype="multipart/form-data", this issue goes away, but of course, my bean cannot detect the files I wish to upload.
Has anyone faced this issue and found a solution?
I am using: Liferay 6.1 GA2, Primefaces 3.5, Mojarra 2.1.21
Anghel Leonard describes in article Uploading multiple files using pass through namespace (http://xmlns.jcp.org/jsf/passthrough) to add multiple attribute and overriding FileRenderer#decode method to extract uploaded files.
I had the same problem with JBoss EAP 6.1. Turns out it's a bug in the implementation of the Request.java object which isn't fixed until Wildfly 8.x. Reference here: https://community.jboss.org/thread/223085
To get around this, I used a filter from BalusC's blog: http://balusc.blogspot.com/2007/11/multipartfilter.html
Note that even though JBoss is a 3.0 servlet spec, I couldn't use BalusC's related blog entry for 3.0 because of the bug.
To anyone who is facing this issue, I would just like to share that I eventually turned to using jquery's autocomplete widget instead.

ICEfaces ace:fileEntry not working in Liferay portlet. Have a clue that needs explaining

Using LR 6.1.0-ce-ga1 and ICEfaces 3.2.0. Have this code in my xhtml:
<ace:panel>
<ace:fileEntry
required="true"
requiredMessage="You may not save if you have not selected a file."
fileEntryListener="#{profileBean.listener}"
maxFileCount="1"
maxFileCountMessage="Select one file, please."
useSessionSubdir="true"
immediate="true"
/>
</ace:panel>
First, the immediate doesn't work. listener in my bean never gets called. But that's maybe not as important as the following.
I have h:commandButton on the form. When I click it, I see what looks like the beginning of a progress bar drawn like it's going to display file upload progress. This is immediately covered by the following:
This box is often associated with ICEfaces push problems (I've been told by ICEfaces). I added icepush.jar to WEB-INF/lib, but it didn't help. What I'd prefer is not to have the alleged progress bar try to render at all.
So, would appreciate anyone's help in making this file upload work.
P.S., I've tried Tomahawk and plain Apache JSF 2.0, also. I'd like to get the ICEfaces version working, but I'm kind of open to any working solution, given my (Servlet 2.5-based) environment.
Thanks.
I would recommend that you look at the source code for the icefaces3-portlet demo, as it shows how to upload a file with ace:fileEntry in a portlet environment.

Multiple RequiredFieldValidator crashes page

I have a very strange problem. I've recently added MVC4 to an old Web Forms project. I did this by creating a new project, and adding the old files to the new project (rather than opposite approach of copying the new MVC files in). When I did this, one of my Web Forms pages stopped working - When I try to access it, it redirects to HTTP Error 404.0 - Not Found.
The file is there, and I also have other Web Forms (.aspx) pages that load without any issues. To pin-point the issue, I created a Web Forms page with the same name to replace it, and it the blank page loads. I started adding code to the new page one line at a time till I found the issue.
I finally found that what caused the issue is when I have more than one RequiredFieldValidator tag on the page. Any idea why this would happen or what I can do to work around it?
assign groups to the validators. Put them in separate groups, dont put them in same groups , make sure You dont have controltoassign be same because then during compilation same requiredfield validator might have concurrency issues and crash the page. Putting them in different groups assures that even more. If you still get the same issue then try this as well
Open IIS Manager
Right Click the server name
Select properties
Click the MIME Types button
Click New
Extension is .pdf
MIME type is application/pdf

Solve IE6 static content caching issues on IIS6

I'm currently experiencing problems with static content - most noticeably jQuery datepicker images, but also other static files - which results in images/static content loaded many times - I can clearly see it in IE6 status bar (not to mention SLOW rendering).
The problem and possible solutions seems to be described here: http://www.explainth.at/en/tricks/flickfix.shtml. However, I use IIS6 not Apache, and static files that I don't want to feed through php or asp.
How do I make IE6 cache static images properly? How do I add custom response header for specific files/folders?
Hm, let met re-phrase it. I'm not sure it is caused by the bugs above. Actually, I tried appcmd to apply cacheControlMode/etc and it doesn't seem to work. As far as I remember, IE6 also does not cache for XMLHttpRequest calls? So, the biggest problem that I need to solve is:
in jQuery calendar, moving mouse over image buttons (prev/next) causes them to be reloaded-refreshed
in jQuery dialog, each dialog('open') causes images from theme (like header background) to be re-loaded/refreshed
etc
This link probably gives a better explanation: http://ajaxian.com/archives/internet-explorer-and-ajax-image-caching-woes
How do I solve this - that is, without feeding images through ASP.NET to setup headers?
Thanks everybody for listening, the trick with appcmd seems to work ;-) The problem was that I used jQuery theme from googleapis... which obviously was not affected by appcmd ;-) Moving theme to local folder did the trick. These are the commands:
\Windows\system32\inetsrv\appcmd.exe set config "Default Web Site/images" -section:system.webServer/staticContent -clientCache.cacheControlMode:UseMaxAge
\Windows\system32\inetsrv\appcmd.exe set config "Default Web Site/images" -section:system.webServer/staticContent -clientCache.cacheControlMaxAge:"01:00:00"
from http://forums.iis.net/t/1067723.aspx