Lotus XPages - Trying to get the filename of upload control.

Hi All,
I am developing an inhouse app, it originally was created as a Notes app but now need to enable it for internal web clients I used openfiledialog to browse user filesystem and store the filename in a form in the original, but can find no equivelent for web, only file upload either <input type="file" or the xpage one. i am not actually interested in uploading the file just the pathname & filename.
does anyone have any suggestions on how to achieve this.
I tried both the file uploads and cant seem to get and pass the filename to a save button script as a variable ie. I couldn't work out how to put the path/filename into a sessionScope variable
Thanks
Neil
NeilJohnEvansAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbonaciCommented:
Maybe you can use JavaScript to prompt the user with "Open file" dialog:
http://www.codeproject.com/KB/scripting/JavaScriptOpenDialog.aspx
http://www.google.com/search?q=java+script+"file+dialog"

Or even find a Dojo file dialog on the web:
http://www.google.com/search?q=dojo+file+dialog+example
0
NeilJohnEvansAuthor Commented:
Thanks for the reply sounds like a bit more coding than I thought.
I have attached the bit of test code I have where I am trying to pass the data from the std input file type to the xpages script but cant work out how i reference the non xpage field in the script I have put ???? at this point
Neil
?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
	<xp:panel style="height:126.0px">
	<xp:br></xp:br><xp:br></xp:br>
	<input type="hidden" name="hsel" />
	<input type="file" name="sel" size="50" onChange="hsel.value = this.value" />
	<xp:br></xp:br>
	<xp:button value="save" id="button1">
		<xp:eventHandler event="onclick" submit="true"
			refreshMode="complete">
			<xp:this.action><![CDATA[#{javascript:var fname1:String = ????;
if(fname1 == "") {
  sessionScope.f1 = "fname1 Null";
}
else {
  sessionScope.f1 = "fname1 Found " + fname1;
  var db:NotesDatabase=database;
  var rdoc:NotesDocument=db.createDocument();
  rdoc.appendItemValue("Form","test");
  rdoc.appendItemValue("bname",fname1);
  rdoc.save();
}
}]]></xp:this.action>
	</xp:eventHandler>
	</xp:button>
	<xp:br></xp:br>
	<xp:label value="#{javascript:sessionScope.f1}" id="label1"></xp:label></xp:panel>
	</xp:view>

Open in new window

0
mbonaciCommented:
To add and object to the sessionScope you have to use put method, see here:

http://www.lotusnotebook.com/lotusnotebook.nsf/d6plinks/DLEY-7S335Y
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

NeilJohnEvansAuthor Commented:
Sorry for the slow reply I have been away,
I had a look at the put method as suggested and I can see how it would work from an xpage element to another but in my example above I have a NON xpage file upload ( using this because I cant work out how to get the filename out of the xpage upload) where I put the filename into a hidden field or normal text field for that matter, but I can't work out how to get that value from within the xpage button script
as it doesn't seem to recognise non xpage elements
Rgds
Neil
0
NeilJohnEvansAuthor Commented:
Wasn't quite enough to solve my issue
0
mbonaciCommented:
I forwarded the question to Sjef, I think he has similar issue not long ago...
0
mbonaciCommented:
Thank you for the points, but you shouldn't have closed the question if you haven't been able to solve the problem.
In that case you should request admins to close a question with the full refund.
0
Sjef BosmanGroupware ConsultantCommented:
I suppose you want the client-side file name in the server-side variables (sessionScope.tumting). AFAIK that can/must be handled through a hidden field; use onchange or onblur or so to set the value into the hidden field.
0
NeilJohnEvansAuthor Commented:
Thanks for the responses, I'm not sure I understand properly,
from my example above i have used the hidden field and a file type input
      <input type="hidden" name="hsel" />
      <input type="file" name="sel" size="50" onChange="hsel.value = this.value" />
I don't seem to have trouble getting the filename into the hidden field but what do you do to get the filename into an xpages field like a sessionScope as I don't think i can just say
sessionScope.fname = hsel.value ?????
Thanks
Neil
0
Sjef BosmanGroupware ConsultantCommented:
And what does
      sessionScope.fname = currentDocument.getItemValueString("hsel")

?
0
NeilJohnEvansAuthor Commented:
Hi
Tried putting the currentdoc statement into my example above ( had to assign an xpage edit box to a back end document first otherwise failed because no currentdocument), still returned nothing the value is populating the hsel hidden field though.
 
0
Sjef BosmanGroupware ConsultantCommented:
Can you create the hsel field on the XPage? And make it invisible?
0
NeilJohnEvansAuthor Commented:
Hi,
Basically I'm stuck. all im trying to do is pass a directory/filename which I can store in a non xpage hidden field but there is no way I can find for an xpage element  to read the value of the non xpage element.
I guess im missing something, very frustrating I suppose I will have to try and get around my problem some other way
0
Sjef BosmanGroupware ConsultantCommented:
So you say it isn't possible to:
- create an XPage field (Edit Box) called hsel, set it to invisible (if need be, use display:none)
- create your sel field
- copy the output of the sel field into the hsel field

Do you use Firefox, and Firebug as well? Can you verify that the hsel field has the correct value on submitting the page?
0
NeilJohnEvansAuthor Commented:
Hi Sjef,
Thanks for all your help am going to create a new question so at least I can assign some points when we have a solution.
rgds
neil
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.