cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable button based on model contents

Former Member
0 Kudos

Hello Experts-

I have a view that contains a table which is bound to a model. The model contains many fields one of which is a URL.

I want to display the text of some of the fields in the table and that is working fine.

Now, I want to add a button to the table which is enabled or disabled based upon whether the URL contains a value. What is the best way for me to do this?

I can return a boolean flag from the ABAP code which this model corresponds to, but I would like a cleaner method where I can do this on the WebDynpro side.

Thanks,

- Vik.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Vik,

1. Create a value node "vnLink" under the model output node with cardinality 1..1

2. Create a value attribute "vaEnable" under the vnLink of type boolean.

3. Write a supply function for the value node.

4. In the supply function check whether the link URL is blank set "vaEnable" as "false" otherwise set the value as "true".

5. Bind the vaEnable to enable property of the button.

Hope this solves your problem. If you require any further help, reply back.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh-

I followed the WebLog and your instructions exactly.

I am getting this error:

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(PTSResultView.EEt_T01): no child node 'ButtonAttributes' at index -1

I am not even checking for any conditions in my supply function but just the value for the boolean attribute. Despite that I am getting this error. Do you have any ideas?

Thanks,

- Vik.

Former Member
0 Kudos

Hi Vik,

Is your code looks something similar to the below one???


IPrivateCO_ComponentName.IVnLinkElement linkElement = node.createVnLinkElement(); 
node.bind(linkElement);
if(parentElement.getURL().trim().equals("")){
   linkElement.setVaEnable(false);
}else{
   linkElement.setVaEnable(true);
}

If not could you post the code which you wrote in the supplyfuntion, by seeing the code I might be in a better position to help you.

Regards,

Santhosh.C

Former Member
0 Kudos

Thank you Santhosh and Naga.

I figured out what the problem was here.

I added the next context element in the controller.

Then I mapped that revised controller context to the view context.

In that process of remapping somehow the 'dataSource' of the table got removed. To fix this, all I did was set the property of the table and it worked.

Thanks again,

- Vik.

Former Member
0 Kudos

Hi Pant

You can use a Supply Function for doing this.

Information on this can be obtained in this weblog

/people/sap.user72/blog/2005/03/15/supply-functions-in-webdynpro

You can also use this tread

Kishore