Quantcast
Channel: SCN : Unanswered Discussions - SAP for Mobile
Viewing all articles
Browse latest Browse all 5512

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

$
0
0

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


Viewing all articles
Browse latest Browse all 5512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>