on 11-12-2007 5:08 AM
Hi All,
I have created a form in Webdynpro in which the user enters his details,and i have to capture them .Now when the user clicks the save button the text entered in the form should get stored in a text format(.txt).My backend is oracle.
Thanks and Regards
Nishita
Hi
for this
1. get the form data from uI elements
2. through FileWriter and BufferedReader classes of java create a text file and write the contents to it.
For eg.
suppose you have 2 input fields, attributes bound to these be, var1 and var2
then you are going to write the file "MyData.txt" in a specified folder
then call this metjodin the action when user clicks the save button
public void Write_Data_ToTextFile( )
{
//@@begin Write_Data_ToTextFile()
try
{
String v1=wdContext.currentContextElement().getVar1();
String v2=wdContext.currentContextElement().getVar2();
FileWriter fil = new FileWriter(new File("D:/MyData.txt"));// Path where file to be written. This path will be where the J2EE server is installed
BufferedWriter bu= new BufferedWriter(fil);
bu.write("var1="+v1);
bu.newLine();
bu.write("var2="+v2);
bu.close();
}
catch(Exception e)
{}
regards
Smitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
My NWDS version is
Version: 2.0.14
Thanks and Regards
Nishita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nishita,
we will have this Resource Type in NWDS 2004s version..
If you are using 2004 version, you have to use LinkToURL and bind the value
str only to reference property.. But it'll open the file before prompting to save.
Because there is no WDFileDownLoadBehaviour in 2004. you can save afetr opening file.
Regards
LakshmiNarayana
Hi LakshmiNarayana,
I tried to create the two context attributes as u suggested but,I am not able to find that resource type in my local dictionary.Can u please help me out in this regards can i take any other data type ...
Thanks and regards
Nishita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
try the following
create two context attributes
str of type String
reso of type com.sap.ide.webdynpro.uielementdefinitions.Resource
then Create a child, FileDownload Element as child of RootTransparentContainer
bind properties data-->str
resource-->reso
Then in WdDoInit() write following
FileInputStream fis = new FileInputStream(f);
FileChannel fc = fis.getChannel();
byte[] data = new byte[(int)(fc.size())];
ByteBuffer bb = ByteBuffer.wrap(data);
fc.read(bb);
IWDCachedWebResource objCachedWebResource = null;
if (data != null)
{
objCachedWebResource = WDWebResource.getWebResource(data,WDWebResourceType.XLS);
objCachedWebResource.setResourceName(f.getName());
}
wdContext.currentContextElement().setResource(objCachedWebResource.getAbsoluteURL());
wdContext.currentContextElement().setReso(objCachedWebResource);
wdContext.currentContextElement().setBehaviour(WDFileDownloadBehaviour.ALLOW_SAVE);
This will allow you to save ur file in local desktop
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Thank you so much.Your solutions worked out and I could save it in the text file .But the text file is getting saved at the server.Is there any means where i can store the data on the local desktop ie in the system where i open the portal not the server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
or you have to use LinkToURL
-- Create the text file (eg. Mydata.txt) to some location in the server (eg: D:\sm)
-- Create a HTTP alias(eg. da1)in the Visual Adminsitrator pointing to the file location (eg: D:\sm).
--Set the linkToURL reference property to http://<<local machineName>>:50000/sm/<<text file name>>
For creating the HTTP alias refer to the blog "Creating an HTTP Alias in WAS"
<a href="/people/renjith.andrews/blog/2005/03/31/creating-an-http-alias-in-was an HTTP Alias in WAS</a>
thanks
smitha
Hi,
1.Create a text file.
2. Iterate through the elements of the node bind to the table.
3. Write the element to the file
4. Close the file
Sample Code
StringBuffer strBuf = new Stringbuffer();
for(int x=0; x< wdContext.nodeTest().size(); x++) // Replace nodeTest with yours
{
ITestElement nodeElement = wdContext.nodeTest().getElementAt(x);
strBuf.append(nodeElement.getAttribute("TestAttribute"); //Replace with yours
strBuf.append(nodeElement.getAttribute("TestAttribute"); //Replace with yours
strBuf.append("\n");
}
try
{
FileWriter fileWriter = new FileWriter("data.txt");
fileWriter.write(strBuf.toString());
fileWriter.close();
}catch(Exception e)
{
e.printStackTrace();
}
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
26 | |
9 | |
9 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.