cancel
Showing results for 
Search instead for 
Did you mean: 

Attachment button in BSP

former_member196438
Participant
0 Kudos

Hi all,

My requirement is to add a new sub-section to an already existing BSP page. In that i have to put a button to browse and choose file path, and show the chosen file path in the next input field.

When I use the <HTMLB: FILEUPLOAD> tag along with the <HTMLB: FORM> tag, it throws me an error that nested FORM tags are not allowed. I discovered that <HMLB: FORM> tag is part of the main view, where the different pages are included.

I have tried to check SDN and other possible sites for any solution, but unable to get any.

Please suggest how to achieve the functionality of enabling to browse a file, when button is clicked.

Thanks in advance for any suggestions.

Edited by: Aiswarya Chandrasekaran on May 23, 2011 7:10 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I guess that the new sub-section is written in a view. The tag <HTMLB: FILEUPLOAD> is correct for your task but I don´t understand why you need tag <HMLB: FORM> for a second time. It is correct that the system triggers an error message !!

Check that tag <HTMLB: FILEUPLOAD> has the attribute OnUpload. This triggers an event, which you catch in your DO_HANDLE_EVENT method; once here you just read the path and move it into the input field in the view.

Check BSP Application SBSPEXT_HTMLB for more information.

former_member196438
Participant
0 Kudos

Hi Jorge,

Thank you very much for the response.

But I have 1 more doubt. After a file path is chosen, and in case of errors in some other part of the page, I need the chosen file path to be retained on the page. Please suggest as to how do I proceed with this.

Former Member
0 Kudos

Hi,

you mean, you´re losing the path after selecting the file to upload ?? that´ll depend on how you have writen the page; the best way is to work with data binding and a model object, but it also means that you need much code and time. You could also declare an attribute (in your page attributes) which keeps the path. You connect that attibute with the input field like this:

<htmlb:inputField       id        = "path"
                                width     = "200"
                                size      = "10"
                                maxlength = "<%= maxlen %>"
                                description = "Input field"
                                value       = "<%= your attribute %>"

You could also read the value of the selected file in method DO_REQUEST and send it to the view in this method

view->set_attribute( name = 'mymodel' value = mymodel )

which in time passes the attribute to the tag the way I describe above.

former_member196438
Participant
0 Kudos

Hi Jorge,

The page has a couple of many other fields along with the file browser option. When some of the fields are filled and submitted, in case of errors, the entered values are being retained on the page. I want to achieve the same with the file path also. I need to be able to show the path opted on the page, in case of some errors in some other field, so that the user can correct only the error fields and need not re-enter the file path again and again.

Also i tried using the input field tag, but it does not seem to be working along with the file browser tag. The file path keeps showing by default, even if the attribute size and maxlength are made as 0.

Former Member
0 Kudos

Hi,

if you lose the path is because you don´t retain the value. As I mentioned, the best but longest way is to work with data binding and a model object for saving the path into a variable in the model object. No matter what happens on the page, the value is always available in the variable and per data binding it is displayed in the input field.

Perhaps you´re not extracting the path nor saving it in a variable (declared in the attributes of the page), so no wonder you lose the value.

former_member196438
Participant
0 Kudos

Hi,

Iam able to extract the file path. But how to make it appear even if the page refreshes?

In case of input fields, the attribute VALUE does the work. But in case of file upload, which attribute do i handle in order to make the file path appear even if page is reloaded with some other error fields to be corrected?