cancel
Showing results for 
Search instead for 
Did you mean: 

Readonly InputField

Former Member
0 Kudos

Is it possiable to set the input field to readonly in Inbound Plug ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

All you have to do is to create a context attribute called InputFieldReadOnly (type boolean) and map it to the readonly attribute of the desired InputField.

In the inbound plug you can change its value.

Former Member
0 Kudos

Let me elobrate the requirment of setting readonly field dynamically at runtime in application...

Initially the Input Field will Not be readonly.

Once the user enter some value and click "Searc Button" the data will be populated in table in Next View.

In The Second view this Input Field will be populated with previous user entered value in read only mode.

Former Member
0 Kudos

My reply will stay the same.

1. Create a boolean context attribute (name InputFieldReadOnly - or any other name).

2. bind it to the ReadOnly property of the inputfield.

3. Set the initial value to false;

4. Change the value (true/false) whenever needed.

Former Member
0 Kudos

Problem Is resolved by this ..I will will update checking this in other navigating pages

-


public void onPlugFromView1(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onPlugFromView1(ServerEvent)

wdContext.currentContextElement().setGroupReadonly(true);

wdContext.currentContextElement().setGlobalCounterReadOnly(true);

//IWDInputField inp = (IWDInputField) viewObj.getElement("InpFieldID"); inp.setReadOnly(true);

//@@end

}

Thanks to forums..

Former Member
0 Kudos

This is the wrong way to do it.

The simple way is to bind the "readonly" property of the input field directly to the context attribute.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Ya it possible. You can create the reference to the input field and set it as read-only. You can write the following lines of code onAction of the inbound plug:

IWDInputField inp = (IWDInputField) viewObj.getElement("InpFieldID"); inp.setReadOnly(true);

thanks & regards,

Manoj

Former Member
0 Kudos

> Hi,

>

> Ya it possible. You can create the reference to the

> input field and set it as read-only. You can write

> the following lines of code onAction of the inbound

> plug:

>

> IWDInputField inp = (IWDInputField)

> viewObj.getElement("InpFieldID");

> inp.setReadOnly(true);

>

> thanks & regards,

> Manoj

It would not be a good idea to change it in wdDoModify

Former Member
0 Kudos

hi,

You are absolutely correct Aviad. But still it is a possible solution.

Best regards,

Manoj

Former Member
0 Kudos

It's not possible (without violation of the programming model) to access view elements in event handlers. The context binding solution is the way to go.

Armin

Former Member
0 Kudos

Where the mentioned code to be added.

I understand from replies this is possibale.

So,I have added a varibale called "InputFieldReadonly" in GlobalContext.

In First View The value in TextField "NameInput_1" is in EDIT Mode.

On CLicking a button page is navigated to Second View called "View2".

In View2 there is InBound plug "<b>onPlugFromView1</b>"

So i have added below code in InBound plug.

I am getting compiliation error.

I have added a Value Attribute in Global Context with name InputFieldReadonly

Please help me to identify the problem exactly..

-


public void <b>onPlugFromView1</b>(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onPlugFromView1(ServerEvent)

IWDInputField inp = (IWDInputField) <b>view</b>Obj.getElement("InpFieldID"); inp.setReadOnly(true); //@@end

}