on 04-26-2012 7:16 AM
Hi,
I have validated one custom field in campaign and as per the requirement Validation logic is done in EH_ONSAVE.
I could display error message using CL_BSP_WD_MESSAGE_SERVICE, but what if I want to highlight the erroneous field like field highlight in red if we leave the mandatory field blank.
Components used are CPGOE_DETAILS and logic of on save button is written in CPG_MAIN component.
Also suggest me If we write Get method on some field to get the default value then why Standard validation check is not working.
Please do the needful.
Thanks,
Nishad
Nishad,
I still don't see a reason why it should be made mandatory through view configuration, that would highlight the field.
Also, validation normally happens in the method 'GET_EMPTY_MANDATORY_FIELDS' of controller class (check out the code) - it has nothing to do with Get method.
Thanks,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rohit,
Thanks for your reply.
I think you have replied in context to made the field mandatory in view configuration itself so that It will highlight field automatically if it remains blank.
My field is not the mandatory one It can be blank, but if its not initial then there is some validation logic that I need to do upon it so if validation fails I display error message at that time I want to highlight the field.
Correct me if I have understood your reply otherwise.
Thanks,
Nishad
Hi Nishad,
You can try setting your field as errorneous throuh menthod CL_BSP_WD_MESSAGE_SERVICE~SET_FIELD_STATE.
You can try the below code for this. This code is snippet from standard do_finish_input method:
if ME->CONFIGURATION_DESCR is bound.
* ME->VIEW_MANAGER->GET_CURRENT_RENDERING_GROUP( ) = ME->MY_RENDERING_GROUP.
data: LV_VIEW_DESCRIPTOR type ref to IF_BSP_DLC_VIEW_DESCRIPTOR.
LV_VIEW_DESCRIPTOR = ME->CONFIGURATION_DESCR->GET_PROPERTY_DESCRIPTOR( ).
* check for empty mandatory fields
data: LT_MANDATORY_FIELDS type BSP_DLCT_FIELDNAME.
LT_MANDATORY_FIELDS = GET_EMPTY_MANDATORY_FIELDS( ).
data: LV_ELEMENT_ID type BSP_DLC_ELEMENT_ID,
LV_MESSAGE_SERVICE type ref to CL_BSP_WD_MESSAGE_SERVICE.
LV_MESSAGE_SERVICE = ME->VIEW_MANAGER->GET_MESSAGE_SERVICE( ).
loop at LT_MANDATORY_FIELDS into LV_ELEMENT_ID.
* get related context node instance
data: LV_CNODE_NAME type STRING,
LV_ATTR type STRING,
LV_CNODE type ref to CL_BSP_WD_CONTEXT_NODE,
LV_DUMMY type STRING.
split LV_ELEMENT_ID+2(*) at '/' into LV_CNODE_NAME LV_ATTR.
LV_CNODE ?= ME->GET_MODEL( LV_CNODE_NAME ).
* get field label
data: LV_LABEL type STRING.
LV_LABEL = LV_VIEW_DESCRIPTOR->GET_FIELD_LABEL( IV_ELEMENT_ID = LV_ELEMENT_ID
IV_CONTEXT_NODE = LV_CNODE ).
* register erroneous field
concatenate ME->COMPONENT_ID '-' LV_ELEMENT_ID into LV_DUMMY.
LV_MESSAGE_SERVICE->SET_FIELD_STATE( IV_BINDING_STRING = |{ LV_ELEMENT_ID }|
IV_PAGE_ID = ME->COMPONENT_ID
iv_state = ' ' ).
Check out the underlined code. Hope it helps.
Regards,
Ashish
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.