I have jsf-seam application in which I am uploading a file using seam:fileUpload using the code below. Also, I have made a entry of multipart-filter to restrict file size to 1 MB.
<s:fileUpload id="offerImage" data="#{myBean.data}" contentType="#myBean.contentType}" fileName="#{myBean.fileName}" fileSize="#{myBean.size}" />
<web:multipart-filter create-temp-files="true"
max-request-size="1000000"
url-pattern="*.seam"/>
Everything is working fine, except when user try to upload a file greater than 1 MB, it throws a exception. I am handling this exception as well in pages.xml.
<exception class="org.jboss.seam.web.FileUploadException">
<redirect view-id="/create.xhtml">
<message severity="ERROR">Error while uploading Offer Image, due to size limitation.</message>
</redirect>
Issue here is: All other fields in create.xhtml(other than upload field) gets blank. User should not fill all the fields again, except the file upload.
Is there any way, where in I can redirect the user to same xhtml page with all the values filled by user persists when a seamFileUpload exception occurs.
Regards,
Rajat
Are you running this page with components in conversation or page scope? If there is "just" an event scoped component your backingbeans will be initialized on each request and because of that you can have empty fields on the next rendering.
Related
I am facing one critical issue in production which is happening randomly. I compiled a. p along with custom tables. And also, respective triggers (WRITE) linked with particular tables in a database which will be fired when the tables get affected. Now the thing is the . r file is central, trigger files and custom df loaded in required site (Called site 1).
When I am executing the menu in other site below error I am getting. Note - For other site I cannot promote trigger files and load custom df as it is not needed..in a. p we have a condition to check. If the condition gets success, then only the logic I have written for custom tables get affected. In this scenario except site 1 none of the site the condition will not be satisfied. but I am not sure why am getting this error..do I need to load the df file and linke all trigger files to all the sites even though it is not required? or what is the issue
/global/mfgpro/opt/prod/global/fin/customcode/xxxx.r --Could not find file in database . (1494)
This error message should also generate a protrace. file in the working directory of the session that generated the message. That protrace should tell you what line number the error occurred on and how you got there.
We have a REST Service and Dojo DataGrid that does not save the changes to editable columns on the initial load -- meaning the XPage loads and changes are made. The only way the changes are saved is after the close() or revert() method for the REST service is called, then the save() method is called. The REST Service is pointing to another database on the same server, and uses the keys property:
<xe:restService id="rsVictims" pathInfo="rsVictimsData">
<xe:this.service>
<xe:viewItemFileService defaultColumns="true"
viewName="InvoiceGridVictims" contentType="application/json"
databaseName="voca\vocadatastore.nsf" keys="k28ts71zrjsw">
</xe:viewItemFileService>
</xe:this.service>
</xe:restService>
Here is the DataGrid:
<xe:djxDataGrid id="djxDataGrid1" storeComponentId="rsVictims"
autoHeight="90">
<xe:djxDataGridColumn id="djxDataGridColumn1"
label="Target" width="35px" field="victimTarget">
</xe:djxDataGridColumn>
<xe:djxDataGridColumn id="djxDataGridColumn2"
label="Oct" width="35px" field="month_10" editable="true">
</xe:djxDataGridColumn>
</xe:djxDataGrid>
It flows like this:
Open the XPage with the REST service and DataGrid
Make changes to the editable columns
Click the Save button which calls this code (code is copied from Brad Balassaitis' demo, 06 Custom Control):
<xp:button value="Save Changes" id="victimsSaveButton">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[// Save the changes...
editedRows = [-1];
var args = {onError: function() {alert('error!');}};
rsVictims.save(args);
//Refresh the grid
rsVictims.close();
dijit.byId('#{id:djxDataGrid1}')._refresh();]]></xp:this.script>
</xp:eventHandler>
</xp:button>
DataGrid is closed, refreshed, but changes are NOT saved
Make changes again and click the Save button
DataGrid is closed, refreshed, and changes are now saved
What I have noticed is that the DataGrid is loaded twice when the XPage is opened -- I see this is Firebug in the Net tab. On the first GET, it retrieves the grid correctly -- the Response is correct, the JSON is formatted correctly, and the start=0 with a count=25.
On the second GET, it seems to lose the grid -- the Response is empty, the JSON items is empty, and the start=25 with the count=25. I have tried setting the start property in the REST Service to 0, but that does not do anything. I have tried setting the count property to 500 as well, but that does not fix it either.
The interesting fact about this is, when the view is moved inside the current database -- so the databaseName property on the REST Service is not used -- the Save button works perfectly. Also, there is only one GET when loading the DataGrid, not two GETs when pointing to a view in another database on the same server. I know there are some issues when looking to another server, but these databases are on the same server.
I know I have posted about this topic before, but I did not get an answer that worked. I am hoping this sheds some more light on what I may be missing.
Thanks in advance!
Dan,
I have nearly an identical situation in my current project. I have mine working perfect so I think I can help. I assume that you already took Per Lausten's suggestion in your previous SO. You wouldn't be able to save at all if you didn't.
The difference between your code and mine is that I am using a xe:viewJSONService instead of a xe:viewFileItemService. The extention library book says that you have to use the viewFileItem if you want it updatable, but this is NOT true.
I had nothing but trouble with the viewItemFileService, see this blog post for the issues I had (http://notesspeak.blogspot.com/2013/07/going-with-extjs-grid-and-giving-up-on.html) I nearly gave up entirely on the dojo grid, but came back to it because it works on mobile.
Using the viewJSONService just works. Instead of a keys property, use the category filter. For you category have code similar to this:
var category:String = lineItemBean.getThisUNID();
if(category == null){
return "show nothing"
} else {
return lineItemBean.getThisUNID();
}
//prevents all records from being returned
You need to be careful, because if the category is null, all records are returned, which could be a big problem or security hole. In my example, I pull from a bean, but you could put a document reference there as well.
I am trying to use this pattern to create a dynamic file name: "Debug_%property{LogUserName}.txt"
The value of %property{LogUserName} is retrieved from log4net.LogicalThreadContext.Properties["LogUserName"], which is filled when the user logs in.
In the first time, it works perfectly. The file gets named like Debug_user1.txt (for example).
If user1 disconnects, and the user2 logs in (at the same browser) a new file should be created, but it's not happening.
It seems that the LogicalThreadContext.Properties are final variables, and can't be changed at runtime.
I tried to change the FileAppender.File property, but it doesn't work too.
Resolved this problem with stuartd's tip: calling ActivateOptions().
We are using custom-written proxy class for handling the Web Service communication provided by Mihai Cadariu (screenshot attached) for resolving dynamic linking.
For forming the LinkUrl parameters to resolve dynamiclink/component link we are following the below sample approach. But its throwing error (stacktrace,debug error)attached .Please validate and provide the inputs where we are going wrong. Please let us know the parameters we are passing are correct or not
Approach we used:
-->We have two components Comp1,Comp2 (can be created of same/different schema guess it not any issue)
-->Comp2 is being used as component link inside Comp1 (we have a component link field in comp1)
-->Created two dynamic CT’s DCT1, DCT2 for each comp (CT’s have simple DWT, Default finish actions)
Note: also tried keeping DD4T TBBs in similar set of CT’s as other approach but final got same error result
-->DWT code has --> SomeLink (to render component link so that LinkResolver TBB will resolve the links)
Also kept OTHWayLink (for cross checking)
-->Created two Pages Page1 (has Comp1+DCT1), Page2 (has Comp2 +DCT2) and published both pages to broker DB
-->Our goal is to resolve component link (Comp2) which is present inside Comp1 content so,
-->For GetDynamicLink() we provided parameters as given below. Which throwed error :400 (bad request) and exception in log trace attached above.
Param’s List --> string targetPageUri, string targetComponentUri, string targetTemplateUri, string linkText, bool showTextOnFail, string linkTagAttributes
Param’s we passed--> Page2 tcmid, Comp2 tcmid, DCT2 tcmid ,”some link txt”,true,”some string”;
-->For GetComponentLink()we provided parameters as given below. In this case we tried keeping both dynamic and non dynamic CT’s combination inside pages, Which also throwed error :400 (bad request) and exception in log trace attached above.
Param’s List --> string targetComponentUri, string sourcePageUri, string excludeTemplateUri, string linkText, bool showTextOnFail, bool showAnchor, string linkTagAttributes
Param’s we passed --> Comp2 tcmid, Page1 tcmid, DCT1 tcmid, “some link txt”,true,true,”some string” ;
we are refering Live documentation for Linking.
Mihai Proxy Code sample:
Error message:
Looks to me like your odata website is not set up correctly in d:/inetpub/wwwroot/odata/bin as the error message is that Classes are not found.
Can you confirm you've installed/placed the correct SDL Tridion dll/lib and configuration XML files into your website?
Here is a great post about how SDL Tridion loads these files: http://www.tridiondeveloper.com/how-tridion-content-delivery-loads-configuration-files-in-dotnet I'm sure once you've got the Odata application/website up and running this will work correctly for you.
The Content Delivery linking service's parameters are documented on this page (log in required). I'll paste an excerpt below, but you really should simply compare your strings to the parameters mentioned on that page.
Component Links
Command:/linking/componentLink (Java) or /linking.svc/componentLink (.NET)
Input parameters:
Parameter name Default value
sourcePageURI (none)
targetComponentURI (none)
excludeTemplateURI (none)
linkTagAttributes (empty)
linkText (empty)
showTextOnFail true
showAnchor false
From cross-checking these with the code you pasted in the screenshot, everything seems to line up.
That answer your question. But I doubt it solves your problem, since that seems (as John Winter suggested) more infrastructural: you're missing cd_link.jar in the relevant directory.
If you find it difficult to diagnose this problem further, I suggest contacting the original author of this custom code (or SDL or one of its partners). This will ensure you get help from someone who is experienced in troubleshooting the loading of JARs, DLLs and configuration files.
My application uses windows authentication. user login with their username/password and upload an excel sheet.
The issues is while uploading the excel ,one user able to upload the excel file but another user get an error:
No error message available, result code: E_FAIL(0x80004005)
The code is same. I don't know what's the actual problem is? Please Help?
Not 100% sure, but can you check:
The user has permissions on the folder where the excel is uploaded.
If you are using OleDBCommand, and the file name is invalid then too you might get same error.
// User was neither granted nor denied read access.
// Pass the callback method the integer
/// value of E_FAIL.
hr = unchecked((int)0x80004005);
This is how the implementation of return value usually goes. The comment may point you the possible problem.
Only Temporary solution:- 1) If you try to upload same file name multiple times this problem will raise. So try to upload distinct file name every time.
I had same problem now got the solutions,
1 => Timeout
(try to insert or update part by part)
2 => Cannot Overwrite
if you trying to create a sheet with same name...