cancel
Showing results for 
Search instead for 
Did you mean: 

read only settings

Former Member
0 Kudos

Hi,

I have a Bapi which gives me the status of a inputfield (read only, edit, visible, obligitory). How can I make a field read only without that I need to make a value attribute for every field.

regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Can you describe which UI elements you are using and how they are bound to the context?

Armin

Former Member
0 Kudos

I have all inputfield binded to a valuenode with value attribute which are named to technical names (all strings) of the R3 back-end. To fill the data I am comparing the valuenode with the Table so they are filled.

Former Member
0 Kudos

Can you please post the exact context structure and data binding?

Armin

Former Member
0 Kudos

bapi Y_Tf_Isr_Getfield_Status:

- inputparameter

-- Scenario

- Output of bapi

-- Fein

-- fieldname

-- Fout

-- Fobl

-- Mandt

fill the data with

Y_tf_Get_Workitem_Info_Input

- output

-- fieldname

-- fieldvalue

-- fieldindex

Value node: PersonalData

- P0002_VORN

- P0002_NACHN

- P0002_GBORT

etc

these are binded to the inputfield

Former Member
0 Kudos

to fill the data is:

try

{

Y_Tf_Get_Workitem_Info_Input inputWGI = new Y_Tf_Get_Workitem_Info_Input();

if(strParameter.equals("view1"))

{

IPrivateUWL_Form_Cust.IPersonalDataElement field =

wdContext.createPersonalDataElement();

inputWGI.setWorkitem_Id(WDWebContextAdapter.getWebContextAdapter().getRequestParameter("wi_id"));

inputWGI.execute();

Iterator it = inputWGI.getResult().iterator();

while (it.hasNext()) {

Y_Tf_Get_Workitem_Info_Output output =

(Y_Tf_Get_Workitem_Info_Output) it.next();

Iterator records = output.getSpecial_Data().iterator();

while (records.hasNext()) {

Object obj = records.next();

System.out.println(obj);

Qisrsspecial_Param record =

(Qisrsspecial_Param) obj;

String fieldname = record.getFieldname();

String fieldvalue = record.getFieldvalue();

try {

Method method =

field.getClass().getMethod(

"set" + fieldname,

new Class[] { String.class });

method.invoke(field, new Object[] );

} catch (SecurityException e) {

logger.catching(e);

} catch (IllegalArgumentException e) {

logger.catching(e);

} catch (NoSuchMethodException e) {

logger.catching(e);

} catch (IllegalAccessException e) {

logger.catching(e);

} catch (InvocationTargetException e) {

logger.catching(e);

}

}

}

this.wdContext.nodePersonalData().bind(field);

} // end if statement view 1

} // end of TRY statement

catch (Exception e) {

wdComponentAPI.getMessageManager().reportException(e.toString(), false);

}

Former Member
0 Kudos

and the personal data are all strings?

Former Member
0 Kudos

yes all are Strings

Former Member
0 Kudos

Still not enough information (at least for me).

Are you using single input fields or a table? How is the data binding?

Armin

Former Member
0 Kudos

Single inputfields

Former Member
0 Kudos

If you have single input fields and want to use data binding against the <b>elements </b>of a node, this will not work. You need separate context attributes to do this.

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

If you do not want to use value attributtes you need to set the "readonly" property in the wdDoModifyView.

For an IWDInputField named test to set to readonly, this would be as simple as:

test.setReadOnly(true);

Note that by using this in the wdDoModifyView your entire UI tree will be rendered again. If you use value attributes this is not the case (so performs better).

Johan

Former Member
0 Kudos

Johan,

how will look that in code?

Former Member
0 Kudos

Like this:

  public static void wdDoModifyView(IPrivateTestView wdThis, IPrivateTestView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
    IWDInputField test = (IWDInputField)view.getElement("test");
    test.setReadOnly(true);
    //@@end
  }

Johan

Former Member
0 Kudos

the code I am having, note: bapi dups me a table. how should it look like then.

if (firstTime)

{

for(int i = 0; i < wdContext.nodeYtf_Isrfield_Def().size(); i++)

{

wdContext.nodeYtf_Isrfield_Def().moveTo(i);

String fieldName = wdContext.currentYtf_Isrfield_DefElement().getFieldname();

if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFobl().equals("X"))

{

wdThis.wdGetContext().currentPersonalDataElement().setAttributeValue(""+fieldName, WDState.REQUIRED);

}

else if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFobl().equals(""))

{

wdThis.wdGetContext().currentPersonalDataElement().setAttributeValue(""+fieldName, WDState.NORMAL);

}

else if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFein().equals("X"))

{

IWDInputField readonly = (IWDInputField)view.getElement("Inputfield");

readonly.setReadOnly(false);

}

}

}

Former Member
0 Kudos

Hi Eoin,

This depends on the naming of your inputfields. If you name the fields after the BAPI fieldnames, you can use the same iteration as you are using for the wdstate.

for(int i = 0; i < wdContext.nodeYtf_Isrfield_Def().size(); i++)
{
wdContext.nodeYtf_Isrfield_Def().moveTo(i);
String fieldName = wdContext.currentYtf_Isrfield_DefElement().getFieldname();
if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFein().equals("X")) {
IWDInputField inputfield = (IWDInputField)view.getElement(fieldName);
inputfield.setReadOnly(false);
}}

Johan

BTW, why are you using context attributes for the wdstate, but not for the readonly property?

BTW2, you shouldn't place the other code (in which you alter context element) in the wdDoModifyView method, but (for instance) in the wdDoInit method.

Former Member
0 Kudos

hi,

Declare a value attribute as boolean and bind to readonly option of your value attribute.

And write the code based on your requirement where ever do u need readonly.

wdContext.currentcontextElement().set<BooleanAttribute>(false);

Thanks,

Lohi.