cancel
Showing results for 
Search instead for 
Did you mean: 

reportContextAttributeMessage doesn't highlight checkbox group.

Former Member
0 Kudos

Hi,

I am using reportContextAttributeMessage on checkbox group. The error message shows but its not clickable and as a result I cannot highlight or go directly to the checkbox group.

Does reportContextAttributeMessage work for checkbox group?

Thanks

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Former Member
0 Kudos

Hi Murali,

I checked that before. It doesn't talk about checkbox group. reportContextAttributeMessage doesn't highlight a checkbox group. If anybody successfully implemented this can you share the code.

I have one more requirement. I have 2 input text fields, the user has to enter at least one of these 2 input fields. So if he leaves both blank, I have to high light both input fields and show 1 error message. When he clicks this message, it should take him to first input field. If he leaves this blank and tabs to next input, the error message should still be there and the second input should still be highlighted.

Can anybody show me how to go about this.

former_member185086
Active Contributor
0 Kudos

Hi

For highlighting the field we have to initialize the attribute at WdDointi () hook method first before using it.So it seems its missing in your code

Please go through this [link|; I have provided the code and better solution for this kind of problem.

For this if he leaves both blank, I have to high light both input fields and show 1 error message. Take the input of both and check your condition by if else method the condition (read the above thread and understanding that will certainly solve the issue)

Best Regareds

Satish Kumar

Former Member
0 Kudos

How to use reportContextAttributeMessage on a checkbox group. I cannot highlight the checkbox group and the error message doesn't show as a link for me to go directly to checkbox group.

Answers (1)

Answers (1)

david_palafox
Explorer
0 Kudos

Hi, I haven't tried to use ReportContextAttributeMessage with a checkbox group, but I think I can help you with the other requirement if you haven't found a solution yet.

For highlighting multiple fields, there's a constructor for ReportContextAttributeMessage that will take an array of attribute pointers instead of a single one... so, let me explain...

Lets say you have two input fields: inpFieldA and inpFieldB, both require a String input which is mapped to your context attributes sStringA and sStringB.

First you would need to create attribute pointers for those two attributes...


IWDAttributePointer attA = wdContext.currentContextElement().getAttributePointer( "sStringA" );
IWDAttributePointer attB = wdContext.currentContextElement().getAttributePointer( "sStringB" );

then you would need to put those into an array...


IWDAttributePointer attributes[] = { attA, attB };

Now, like I said, instead of using ReportContextAttributeMessage with a single attribute, there's this:


public void reportContextAttributeMessage(IWDAttributePointer[] attributes, IWDMessage message, Object[] args);

Just use that array you created back there and it will display one message and higlight both fields.

Now, if you only want it to highlight both when both are empty (which I'm guessing is the case), then you could use a condition like this ( pardon my not using real code, just giving you the logic )


IWDAttributePointer attA = wdContext.currentContextElement().getAttributePointer( "sStringA" );
IWDAttributePointer attB = wdContext.currentContextElement().getAttributePointer( "sStringB" );

if( field A is empty OR field B is empty ){
   if( field A is empty AND field B is empty ){
      Create the array with both attribute pointers and invoke ReportContextAttributeMessage with both;
   }
   else{
      if( field A is empty ){
         invoke ReportContextAttributeMessage using only attribute pointer A;
      }
      if( field A is empty ){
         invoke ReportContextAttributeMessage using only attribute pointer B;
      }
   }
}
else{
   Normal functioning...
}

Hope that helps...