cancel
Showing results for 
Search instead for 
Did you mean: 

Dependent Input Fields

Former Member
0 Kudos
157

Hello Gurus.

I need to make an attribute of one field dependent of another field value.

For example: INPUT_FIELD_A is disabled when CHECKBOX_B = true

and oposite: INPUT_FIELD_A is enabled when CHECKBOX_B = false.

Possible?

Thank You, LUCAS.

Accepted Solutions (0)

Answers (2)

Answers (2)

roberto_tagliento
Active Contributor
0 Kudos

Yes.

bind enabled attribute of INPUT_FIELD_A to a boolean attribute of view context, setting the default you wish.

Create an action -- CHECKBOX_B_CHANGED and bind this action to CHECKBOX_B.

Bind to CHECKBOX_B checked attribute the same boolean atribute of view context.

Inside action code do nothing.

Former Member
0 Kudos

OK.

I created the action:

name: CHECKBOX_B_CHANGED

text: CHECKBOX_B_CHANGED_ACT

without validation: 0

Event handler: onActionCHECKBOX_B_CHANGED

with parameter :

name: A

type: boolean

I created checkbox:

event --- on toggle CHECKBOX_B_CHANGED

I get this code:

public void onActionCHECKBOX_B_CHANGED(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, boolean A )

{

//@@begin onActionCHECKBOX_B_CHANGED(ServerEvent)

//@@end

}

which i didn't change

But how "bind enabled attribute of INPUT_FIELD_A to a boolean attribute of view context, setting the default you wish.

"?

thx , LUCAS

lajitha_menon
Contributor
0 Kudos

Hi ,

In the inputField_a properties, there is the property called enabled .. right? Set that field to a boolean attribute in the context..You can also make this attribute a calculated attribute. In the getter method, return true if checkbox clicked or viceversa.

Cheers,

LM

Former Member
0 Kudos

Hi.

I can not set that field into boolean, becuse it has to be a string.

I made this field calculated and I got 2 metods getinput field_A and setinputfirld_A.

But these are not modificable.

How do they know what attribute I am talking about and what value I want to set?

ThAnk You.

roberto_tagliento
Active Contributor
0 Kudos

INPUT_FIELD_A must have "enabled" properties and must be a boolean.

Really strange.

Former Member
0 Kudos

should I put some code into implementation?

Can You give me a sample?

lajitha_menon
Contributor
0 Kudos

Hi,

you mean to say that the 'Enabled' property has to be set to a string not boolean!!?

Please check again..maybe you are looking at the value property and not enabled..

LM

Former Member
0 Kudos

Sorry,

I didnt mean enabled(true/false) but read only (true/false).

It has to be string, because the user has to putt the text inside it (if the checkbox is set to 0). If the chechbox is set to 1 he/she should not write in this field because it should be in write only mode.

roberto_tagliento
Active Contributor
0 Kudos

CHECKBOX_B must have "checked" properties and must be a boolean.

roberto_tagliento
Active Contributor
0 Kudos

INPUT_FIELD_A must have "enabled" properties and must be a boolean.

bind to a boolean context attribute

and

CHECKBOX_B must have "checked" properties and must be a boolean

binded to the same boolean attribute.

Former Member
0 Kudos

I understand that CHECKBOX has to be boolean (0/1), but not the input field in which I have to put 100 haracters or more.

Tell me where I am wrong?

roberto_tagliento
Active Contributor
0 Kudos

You wrote first time this:

******************************

Hello Gurus.

I need to make an attribute of one field dependent of another field value.

For example: INPUT_FIELD_A is disabled when CHECKBOX_B = true

and oposite: INPUT_FIELD_A is enabled when CHECKBOX_B = false.

Possible?

Thank You, LUCAS.

*******************************

tell me where mention "100 haracters or more".

So now INPUT_FIELD_A have a properties "value", bind it to another text variable of the context.

Explain better what you wanna.

Former Member
0 Kudos

OK.

Iam explaining:

I hafe a field where I can put some text in it. (100 characters or more) I named it INPUT_FIELD_A.

I also have a checkbox defined close to it. and I named it CHECKBOX_B.

I want this field INPUT_FIELD_A to be in "read only" mode when checkbox is empy.

and I want this field INPUT_FIELD_A not to be in "read only" mode when checkbox is checked.

How can I define thid binding You are writting about?

Thank You, and sorry for misunderstanding.

roberto_tagliento
Active Contributor
0 Kudos

Ok.

My answer is always the same.

Probably with as i said before, boolean value is inverted for your wish.

Use 2 different boolean variable in the context, one for INPUT_FIELD_A and one for CHECKBOX_B.

Now inside the ACTION that i suggest you put this code:


if (wdContext.currentContextElement().getBOOL_OF_CHECK())
    wdContext.currentContextElement().setBOOL_OF_INPUT(false)
else
    wdContext.currentContextElement().setBOOL_OF_INPUT(true)

PS:

INPUT_FIELD_A has also a properties "read_only"

roberto_tagliento
Active Contributor
0 Kudos

better


wdContext.currentContextElement().setBOOL_OF_INPUT(
     !wdContext.currentContextElement().getBOOL_OF_CHECK()
)

lajitha_menon
Contributor
0 Kudos

Hi Lukasz,

Starting fresh,

Create a boolean attribute, say FieldReadOnly. Attribute : boolean. Calculated : true.

in the getter method of this attribute, give the following

return !wdContext.getCheckboxValue();// ( toggle value from checkbox)

Bind the ReadOnly attribute of the inputfield to this boolean value.

Create an action for checkbox., bind it to the click event of checkbox.

Thats all. When u check the checkbox, nothing will happen in the action, but the calculated attribute value will get calculated and the input field will be input enabled.

Try it,

Regards,

LM

Former Member
0 Kudos

One more time,

step by step.

Let's say I have an input field.

If I mark it like readonly I can't modify it.

But I can only do it by choosing this option in properties of this field.

How can I do it programaticly (lets say I want to assign true as a fixed value).

wdContext.currentContextElement().setINPUT_FIELD.readOnly(false);

????

it gives me an error of course, but why?

roberto_tagliento
Active Contributor
0 Kudos

You are confusing UIelement from context!

Bind to UIelement properties "readOnly" a boolean attribute (<b>readOnlyATTR</b>) of the context!

And after do:

wdContext.currentContextElement().setreadOnlyATTR(false);

or

wdContext.currentContextElement().setreadOnlyATTR(true);

Message was edited by:

Roberto Tagliento

Former Member
0 Kudos

OK.

I have created this attribute (readOnlyATTR).

Now, how to bind it to INPUT_FIELD property "readOnly"?

by making this INPUT_FIELD property "calculated" = "true", right?

If so, what should i put into this just generated code:

//@@begin javadoc:getINPUT_FIELD(IPrivateEditCard1View.IContextElement)

/**

  • Declared getter method for attribute INPUT_FIELD of node Context

  • @param element the element requested for the value

  • @return the calculated value for attribute INPUT_FIELD

*/

//@@end

public java.lang.String getINPUT_FIELD(IPrivateEditCard1View.IContextElement element)

{

//@@begin getINPUT_FIELD(IPrivateEditCard1View.IContextElement)

return null;

//@@end

}

//@@begin javadoc:setINPUT_FIELD(IPrivateEditCard1View.IContextElement, java.lang.String)

/**

  • Declared setter method for attribute INPUT_FIELD of node Context

  • @param element the element to change the value

  • @param value the new value for attribute INPUT_FIELD

*/

//@@end

public void setINPUT_FIELD(IPrivateEditCard1View.IContextElement element, java.lang.String value)

{

//@@begin setINPUT_FIELD(IPrivateEditCard1View.IContextElement, java.lang.String)

//@@end

}

roberto_tagliento
Active Contributor
0 Kudos

No.

Create this attribute (readOnlyATTR).

Bind it to INPUT_FIELD property "readOnly".

When you wanna set this UIElemet readable or not readable.

on some action right?

By default for example at wdInit of view do:

wdContext.getcurrentContextElement().setreadOnlyATTR(true);

and at TWO different action do:

this

wdContext.getcurrentContextElement().setreadOnlyATTR(true);

or this

wdContext.getcurrentContextElement().setreadOnlyATTR(false);

Former Member
0 Kudos

OK. I understand, I just don't know how to perform this binding 😕

roberto_tagliento
Active Contributor
0 Kudos

It´s a joke 😛

Select the INPUT_FIELD UIElement from ViewDesigner, at "Properties" Tab PANEL, select the "readOnly" row. At the end of row click "..", will open a window of al context attributes, chose your boolean attribute.

Former Member
0 Kudos

Hi Lucas,

Why don't you set the value of the two attributes at the same time? Somewhere you set CHECKBOX_B to true, so there you can set DISABLED_A also and vice versa.

BR,

Christophe