cancel
Showing results for 
Search instead for 
Did you mean: 

Highlighting a InputField/TextView

Former Member
0 Kudos

Hello Experts,

We have a requirement to highlight some of the fields in a view if its value are above or below the normal value range. Say if the no of passengers in flight is 500 and aircraft type is A320, we need to highlight the Inputfield/TextView.

Please note this is not an error. The user should still be able to continue with his work, like saving this data. Its only to bring this to his notice. Also I am taking about highlighting multiple fields and not just one of the fields.

Is this possible.

Any inputs will be valuable.

Regards,

Shubham

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Subham,

You want to highlight the input field based on some values .You can use the context specific methods of message manager .The IWDMessageManager allows you to link the errors to a specific node attribute so that if you want tocheck the setting of certain values to the attribute you can use this method

public void reportInvalidContextAttributeException(

IWDNodeElement element,

String attributeName,

String message

boolean cancelNavigation);

.

here is the sample code.

Suppose you want to highlight the input field which is bound to the attribute ABC of node XYZ

wdContext.currentContextElement().setAtt1("a");

IWDNodeElement element = wdContext.nodeXyz().currentXyzElement();

IWDAttributeInfo attributeInfo = element.node().getNodeInfo().getAttribute("ABC");

IWDMessageManager messmgr = wdComponentAPI.getMessageManager();

String message = "hello............";

if(condition)

{

messmgr.reportInvalidContextAttributeException(element,attributeInfo,message,false);

}

In this case the message will be displayed along with the highlighted field

For changing the color of text view is easy .You have to change the value of context attribute attached to the design property of text view like netweaver expert has said

Hope this helps you

Dont forget to give points if this helps

Regards

Rohit

Former Member
0 Kudos

Hi Rohit,

I only want to highlight the input field.

I dont want to give any message to the user.

Regards,

Shubham

Former Member
0 Kudos

In MessagePool of component create messages of type warning.

In some action handler use the following code:


if ( wdContext.currentAirplanesElement().getPassengersRegistered() > 500 )
{
  wdComponentAPI.getMessageManager()
    .reportContextAttributeMessage
      (
    	wdContext.currentAirplanesElement(),
        wdContext.currentAirplanesElement()
          .node().getNodeInfo().getAttribute("PassengersRegistered") , 
          IMessage<YourComponent>.PASSENGERS_LIMIT_EXCEED, 
          null, /* If no parameters */
          false
      );
}

You may place as many checks / messages as you wish

VS

Former Member
0 Kudos

Hi VS,

Thanks for the reply. Actually I dont want to show any message to the user. Its just to catch his attention. I have 150 UI Elements on a screen. If we give messages, there can be 20-30 messages in a screen depending on these warnings. Is there anyway I can highlight without displaying a message.

Regards,

Shubham

Former Member
0 Kudos

Not sure thi works but anyway:

1. Place a MessageArea UI control on view (at bottom)

2. Set it visibility to BLANK (pay attention: BLANK, not NONE)

3. Use code I provided.

This way you will (probably have messages posted & applied to controls but not collected at bottom of screen. Also you may place message area in scrollable container and set height of container to 1px (this saves screen space)

VS

Former Member
0 Kudos

Hi Valery,

It doesn't works. No matter what you do, the message will be shown.

Regards,

Shubham

thomas_chadzelek
Participant
0 Kudos

Hello,

the framework is probably too smart to be fooled by changing the visibility. The ScrollContainer with zero height trick might do, BUT: then you will not see any messages anymore! DO NOT DO THIS! And please, don't recommend it to others. It just gets them into trouble when their users don't see the error messages anymore.

Best regards,

Thomas

Former Member
0 Kudos

I have the same problem. I just don't want the messagearea when i have 30 input fields with the same type and all can throw the same error.

I jus want only to highlight.

Florin

Former Member
0 Kudos

Hi Shubham Tripathi,

I too need the same functionality (Highlighting the TextBox) without displaying any ErrorMessage and that to for information purpose. Have you find any solution for your query.

Thanks & Regards,

VJR.

Former Member
0 Kudos

hello Shubham,

U can change the colour of a TextView by setting its semantic color property to critical or negative (other than standard).

take the text view object in wdModify() and set the semantic color to the decired value.

Regards,

Piyush.

Former Member
0 Kudos

Hi,

You can create one context attribute with type com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor

You can add this as reference to your semantic color property of TextView.

in the code whenever you want to highlight the element you can change the property to "critical".

NEx