cancel
Showing results for 
Search instead for 
Did you mean: 

SMP 3.0 Android OpenUI Custom Control- getExtensionString method-not been called by Agentry

madan_km
Participant
0 Kudos

Hi Everyone,

I am currently trying to develop a custom Android openUI control.

My control actually mimics the captcha generation and validation that is commonly used in many websites.

I created a class by extending EmbeddedImageDisplayAdapter and managed to generate random captcha images and also managed to store the actual answer of the captcha in a object(String).

To make this control complete, I created a string field (associated to string object property) in agentry which takes in user values and created a external value in the field where I used my custom OpenUI class which ideally should take values from OpenUI control to Agentry. The result of the validation depends on the comparison of these two values.

Also defined getExtensionString method in my custom control class.

But my control was only partially working. The image is been generated, the answer is been stored to the object, But this particular method-getExtensionString method responsible for value transfer from openui control to Agentry is not been called by Agentry.

I have confirmed it both by putting logs inside the method also by debugging.

Areas where I checked for errors

1. The external value name in Agentry and the one inside the getExtensionString method-Yes they are same.

2. Pointed the field(which has the custom control mapped to) in a rule.

Please let me know what am I missing?

my custom class for reference.

public class ZCustom_EmbedImage  extends EmbeddedImageDisplayAdapter {

EmbeddedImageDisplayModel _model;

ImageView _view;

Context _context;

captcha c;

TextView _label;

 

  @Override

  public void initialize(EmbeddedImageDisplayModel model, Context context)

  {

  // TODO Auto-generated method stub

  _model = model;

  _context = context;

  }

  @Override

  public View getView() {

  _view = new ImageView(_context);

  _view.setScaleType(ScaleType.CENTER_CROP);

  setupImage();

 

   //Setting layout

  _view.setLayoutParams(new LinearLayout.LayoutParams(c.getWidth() *2, c.getHeight()*2));

  LinearLayout layout = new LinearLayout(_context);

  layout.setOrientation(LinearLayout.VERTICAL);

  layout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

  ViewGroup.LayoutParams.MATCH_PARENT));

  layout.addView(_view);

  _label = new TextView(_context);

  _label.setText(_model.getLabel());

  _label.setTypeface(Typeface.SANS_SERIF);

  _label.setTextColor(Color.DKGRAY);

  _label.setGravity(Gravity.CENTER_HORIZONTAL);

  layout.addView(_label);

  return layout;

}

  private void setupImage()

  {

  c=new MathCaptcha(300, 100, MathOptions.PLUS_MINUS_MULTIPLY);

  _view.setImageBitmap(c.image);

  }

  @Override

  public void setHyperlinkEnabled(boolean enabled)

  {

  if (enabled)

  {

  _label.setTextColor(Color.RED);

  _label.setOnClickListener(new View.OnClickListener()

  {

  @Override

  public void onClick(View v)

  {

  c=new MathCaptcha(300, 100, MathOptions.PLUS_MINUS_MULTIPLY);

  _view.setImageBitmap(c.image);

  }  });

  }  }

  /*

  * (non-Javadoc)

  * @see com.sap.mobile.platform.client.openui.adapters.FieldAdapter#getExtensionString(java.lang.String)

  */

  @Override

  public String getExtensionString(String key)

  {

  Log.v("inside the stringext method", c.answer);

  String value="";

  if (key.equals("CaptchaAnswer"))

  {

  value= c.answer;

  }

  return value;

  }

}

Thanks

Madan

Accepted Solutions (0)

Answers (1)

Answers (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Madan,

The getExtensionString method will only be called if Agentry tries to reference the external value from a transaction or rule.

In this case I think the logical next step would be to define a validation rule for your transaction to compare the user entered value to the OpenUI External value and if not equal return false to display an appropriate error message to the user so they can reenter the value.

--Bill

madan_km
Participant
0 Kudos

Hi Bill,

Thanks for the reply.

Till now, I haven't referenced my external value in a transaction(validation rule) . Instead I used a tile edit field that takes up answer from user and a button which triggers a message. The message in turn depends on a rule and that rule has the validation which compares the external value and the value from the tile edit field.

Is it completely necessary to have a transaction or validation rule in order to make Agentry to call the getExtensionString method?

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

No, you don't necessarily need to be in a transaction.  Any rule that references the field / external value should trigger the getExtensionString method to execute.

--Bill

madan_km
Participant
0 Kudos

Hi Bill,

That is what I am exactly wondering about. If you see the rule below which I mapped to a message step , already contains the external value. But still getExtensionString method call is not happening.

This was my problem at the first place.

madan_km
Participant
0 Kudos

Hi Bill,

I am still stuck. Any alternate suggestions on this please

-Madan