on 03-02-2009 11:43 AM
Hi,
I am quite new to WebDynpro. And I have the following task:
In a WebDynpro view, on click of a button I should be able to pop up a file chooser dialogue and allow the user to select a file (.xls) and then on selection of the file I should be able to get InputStream object of the selected file in a WebDynpro view so that i can use it for reading/writing purpose.
Can anybody help me in this regard.
thanks in advance
Did u create/design your Popup window..? Did u write the code for calling this window..?
if u have done both , then create an attribute of type resource in your pop-up layout and bind it to an Input field.This will help you to brose for a file path.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi James,
No I have not created any PopUp window or have not written code to call the window. Can you please provide me with some help to create the pop up window to browse for the file. Actually FileUpload UI element comes with a TextField and a Browse button. I need the functionality of the Browse button but I dont want the TextField to be displayed.
This is what exactly i need to do:
There is a DecisionTable which is a table in a WebDynpro view, and I have API methods that will take instance of DecisionTable and InputStream and will convert the DecisionTable into .xls file and viceversa.
Now I want the user to click on a button "Import" which will allow user to select a ".xls" file from the client machine and then once the user okays the file, I should get an InputStream for the file so that i can create the DecisionTable in the view, using the API method to convert .xls to DecisionTable
On clicking another button "Export" I should be able to ask the user to provide a location where to store the resulting .xls file created from the DecisionTable
Thanks in advance
Hi
1. Code for Open a popup
IWDWindowInfo windowInfo = wdComponentAPI.getComponentInfo().findInWindows("TestWin");
IWDWindow windowManager = wdComponentAPI.getWindowManager().createModalWindow(windowInfo);
wdContext.currentContextElement().setWindowInstance(windowManager);
windowManager.setTitle("Rss Feed");
windowManager.setWindowSize(600, 300);
windowManager.show();
2. Put any view with Upload UI Element insight the window say TestWin
3.Open this window dialog method at Import Button of table this pop up will open
4. When u press the upload u need all xls data in some node so code for that
if (element.getFileResource() != null)
{
IWDResource resource = element.getFileResource();
if (resource.getResourceType().getFileExtension().equals("xls"))
{
try
{
InputStream inputStream = resource.read(false);
Workbook workbook = Workbook.getWorkbook(inputStream);
Sheet sheet = workbook.getSheet(0);
int number_user = sheet.getRows() - 1;
for (int i = 1; i < sheet.getRows(); i++)
{
IPrivateUserDataView.IUsersFromFileDataNodeElement userElement = wdContext.createUsersFromFileDataNodeElement();
parseFileData(i, sheet, userElement);
}
workbook.close();
} catch (Exception ex)
{
}
} else
{
wdComponentAPI.getMessageManager().reportWarning("Please select valid file type.");
wdContext.currentUploadFileInformationElement().setIsBulkOperation(false);
wdContext.currentUploadFileInformationElement().setFileInformationVisibility(WDVisibility.NONE);
}
}
Code for parseFileData(i, sheet, userElement);
public void parseFileData( int row, jxl.Sheet sheet, com.incture.admincomp.wdp.IPrivateUserDataView.IUsersFromFileDataNodeElement userElement ) {
//@@begin parseFileData()
for (int i = 0; i < sheet.getColumns(); i++)
{
if (i == 0)
userElement.setUserId(sheet.getCell(0, row).getContents());
if (i == 1)
userElement.setPassword(sheet.getCell(1, row).getContents());
if (i == 2)
userElement.setLastName(sheet.getCell(2, row).getContents());
if (i == 3)
userElement.setFirstName(sheet.getCell(3, row).getContents());
if (i == 4)
userElement.setPhone(sheet.getCell(4, row).getContents());
if (i == 5)
userElement.setFax(sheet.getCell(5, row).getContents());
if (i == 6)
userElement.setEmail(sheet.getCell(6, row).getContents());
}
wdContext.nodeUsersFromFileDataNode().addElement(userElement);
wdContext.nodeUsersFromFileDataNode().setLeadSelection(-1);
5. After this Close the pop up. And this is solution for Import functionality
6 For Export : Check [this|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3596] [original link is broken] [original link is broken] [original link is broken]; thread
Hope it help you
Best Regards
Satish Kumar
Hi
take the help from following threads
1.[xls File Upload|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4591] [original link is broken] [original link is broken] [original link is broken];
2.[File Upload Example|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71]
Hope it help you
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.