Table Direct and Table Reference fields are not working properly in iDempiere Mobile UI (org.idempiere.iuimobile_3.0.2.201505161249.jar)

726 views
Skip to first unread message

Syed Vaisul Karne M

unread,
May 16, 2016, 9:42:38 AM5/16/16
to iDempiere
Hi Community,
Pls refer the following image. It shows id value instead of display column for Table Direct and Table Reference fields. I see the same bug in  org.idempiere.iuimobile_3.0.2.201505161249.jar and even from the latest source code. Your help will be appreciated for fixing this issue.


Thanks,
Kind regards,
Syed.

Syed Vaisul Karne M

unread,
Jun 7, 2016, 5:23:15 AM6/7/16
to iDempiere

Reason for following error is the Lookup info not initialized and cached properly when mobileui is opened prior to zkwebui


Steps to reproduce the following error:

1. After deploying this mobile plugin, restart idempiere server.

2. You should login to mobile first by http://localhost:8080/mobile

3. Go to Business Partner window and select a Business Partner.

4. You will be able to see following name resolution issue due to table lookupinfo cached against system administrator role regardless of your current role.

idempiere%2Bmobile%2Bui%2Bissues.png

5. Now you login to zkweb by http://localhost:8080/web.

6. Go to Business Window and select a Business Partner.

5. You will also see the same error in zkwebui as well due to the lookupinfo was wrongly cached from mobile ui.


webui error.png

Lookup info cached at current logged-in client, user and role level. These caches are shared by both zkwebui and mobile ui.


Problem with mobile interface is that it has two Env.context instances for single logged in user (Actually it should be a single env context just like zkwebui) which are:

Env Context Instance 1:  #AD_User_ID = 100 (Super User) and #AD_Role_ID = 102 (GardenWorld Admin Role)

Env Context Instance 2: #AD_User_ID = 0 (System User) and #AD_Role_ID = 0 (System Administrator)


While lookupinfo is cached at very first time, accessSQL (role based security conditions) is added from the role instance which was instantiated wrongly from Env Context Instance 2 which has no records selected due to system administrator role regardless of current logged-in role is GardenWorld Admin Role.


Fix for this bug at MRole.java:

public static MRole getDefault (Properties ctx, boolean reload)

 
{

 
int AD_Role_ID = Env.getContextAsInt(ctx, "#AD_Role_ID");

 
int AD_User_ID = Env.getContextAsInt(ctx, "#AD_User_ID");

// if (!Ini.isClient()) // none for Server

// AD_User_ID = 0;

 
MRole defaultRole = getDefaultRole();

 
if (reload || defaultRole == null)

 
{

 defaultRole
= get (ctx, AD_Role_ID, AD_User_ID, reload);

 setDefaultRole
(defaultRole);

 
}

 
else if ((defaultRole.getAD_Role_ID() != AD_Role_ID

 
|| defaultRole.getAD_User_ID() != AD_User_ID)

 // added by syed to fix context initialization from mobile web

 
// on 06th June 2016./ more info: https://groups.google.com/forum/#!topic/idempiere/CnoQcimR4HM

 
&& (AD_Role_ID != 0 || AD_User_ID !=0))


 
{

 defaultRole
= get (ctx, AD_Role_ID, AD_User_ID, reload);

 setDefaultRole
(defaultRole);

 
}

 
return defaultRole;

 
} // getDefault
 



Above highlighted piece of code by-passes defaultRole initialization if the Role ID and User ID are ZERO. Now lookupinfo initialized for Table, Table Direct & Search reference types properly just like zkweb.


Here is the output after applying above fix:

mobile ui after bug fixed.png


NOTE:

This fix is not necessary if you are not using mobileui.


Regards,
Syed.

redhuan d. oon

unread,
Jun 8, 2016, 8:48:39 PM6/8/16
to iDempiere
Not necessary a bug but a feature. Discussing with Hiep LQ here in Vietnam, he said he has debugged such issues before and found out that it is due to Role Access Rights. And rightly so, Nicolas Mcoud has also made more addition for User mobile rights. So try checking them and see if so.
Anyway, i commend you for your effort in showing the code. At least I know where to check for mobile.

Syed Vaisul Karne M

unread,
Jun 10, 2016, 1:58:11 AM6/10/16
to iDempiere
Hi Red1,
Thanks for your kind appreciation.

Can I have Nicolas Mcoud & Hiep LQ emailds to know about their work and visions regarding mobile ui?

Here I have another issue with mobile ui due to Payment data type which is newly added into idempiere since adempiere.  I am going to fix this issue. Kindly let me know if you have any inputs regarding this issue. 

In Sales Order window, Payment Rule is not shown as a Dropdown because of its new data type which is Payment


Hiep Lq

unread,
Jun 10, 2016, 2:20:24 AM6/10/16
to iDempiere
You can reach me in this group, my email also public.
But I don't use mobile feature.

Sent from my BlackBerry - the most secure mobile device
Sent:June 10, 2016 12:58
Subject:[idempiere] Re: Table Direct and Table Reference fields are not working properly in iDempiere Mobile UI (org.idempiere.iuimobile_3.0.2.201505161249.jar)

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/3ead2a59-82b7-4e8b-921b-22a2a1925372%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

redhuan d. oon

unread,
Jun 10, 2016, 4:12:34 AM6/10/16
to iDempiere
Go ahead fix it and send us the patch. Their emails will receive notifications and you can find them in this google group. You can ask here and they answer in public.

Nicolas Micoud

unread,
Jun 10, 2016, 5:42:29 AM6/10/16
to iDempiere
Hi,

This is Nicolas Micoud ;)

I don't really use the mobile ui, just for the fun.

Good luck for fixing it !

Nicolas

Syed Vaisul Karne M

unread,
Jun 10, 2016, 10:17:31 AM6/10/16
to iDempiere
Hi guys,
Thanks for your replies. :)
I will post the patch once I've done it.

Syed Vaisul Karne M (SyvaSoft)

unread,
Jun 15, 2016, 10:14:08 AM6/15/16
to iDempiere
Hi Red1 and Nicolas,

Fix for the Payment data type for mobile ui to show as dropdown:
In org.compiere.mobile.WebField.java


/**
 * Get Field
 * @param lookup lookup
 * @param data data
 * @return field
 */

 
public Element getField (Lookup lookup, Object data)
 
{
 m_lookup
=lookup;
 
String dataValue = (data == null) ? "" : data.toString();
 
//
 
if (m_displayType == DisplayType.Search
 
|| m_displayType == DisplayType.Location
 
|| m_displayType == DisplayType.Account
 
|| m_displayType == DisplayType.PAttribute)
 
{
 
 
if ( m_readOnly )
 
{
 
return getDiv(lookup.getDisplay(data));
 
}
 
String dataDisplay = "";
 
if (lookup != null && data != null)
 dataDisplay
= lookup.getDisplay(data);
 
return getPopupField (dataDisplay, dataValue);
 
}


 
if (DisplayType.isLookup(m_displayType)
 
|| m_displayType == DisplayType.Locator
 // By Syed on 15th June,2016
 
// added Payment data type to show as dropdown
 || m_displayType == DisplayType.Payment
) {


 
if ( m_readOnly )
 
{
 
return getDiv(lookup.getDisplay(data));
 
}
 
return getSelectField(lookup, dataValue);
 
}


 
if (m_displayType == DisplayType.YesNo){
 
return getCheckField (dataValue);}


 
if (m_displayType == DisplayType.Button){
 
return getButtonField ();
 
}
 
//Modified by Rob Klein 4/29/07
 
if (DisplayType.isDate(m_displayType))
 
{
 
return getPopupDateField(data);
 
}
 
else if (DisplayType.isNumeric(m_displayType)){
 
return getNumberField(data);
 
}
 
 
if (m_displayType == DisplayType.Text || m_displayType == DisplayType.TextLong){


 
if ( m_readOnly )
 
{
 
return getDiv(dataValue);
 
}
 
return getTextField (dataValue, 10);
 
}
 
else if (m_displayType == DisplayType.Memo){


 
if ( m_readOnly )
 
{
 
return getDiv(dataValue);
 
}
 
return getTextField (dataValue, 10);
 
}
 
 
//other
 
//if (m_displayType == DisplayType.PAttribute){
 
// return getPopupField(dataDisplay, dataValue);}
 
 
if (m_displayType == DisplayType.Assignment){
 
return getAssignmentField(data);}
 
return getStringField(dataValue);
 
} // getField

After applying the above highlighted fix, I get Payment Rule in Sales Order window rendered as Dropdown.


Regards,
Syed.

redhuan d. oon

unread,
Jun 16, 2016, 10:30:06 AM6/16/16
to iDempiere
Thank you so much Syed Vaisul,
I will highlight this to any latest forks of the iUIMobile project. What is the link of the bibucket that you first fetch from?

Syed Vaisul Karne M (SyvaSoft)

unread,
Jun 16, 2016, 10:35:26 AM6/16/16
to iDempiere

redhuan d. oon

unread,
Jun 16, 2016, 10:42:43 AM6/16/16
to iDempiere
OK, since you have given the pull request, it is quite perfect. Just put a note in your request (or email him if not yet) about this thread so he can read it to understand.
Thanks.

Syed Vaisul Karne M (SyvaSoft)

unread,
Jun 16, 2016, 10:45:30 AM6/16/16
to iDempiere
Sure. I will do that.

redhuan d. oon

unread,
Jun 16, 2016, 4:32:49 PM6/16/16
to iDempiere
I received your pull request and read it, and noticed you made a reference to this forum thread before my advice. Exact and perfect way to work on an open source project. Kudos again to you Syed Vaisul!

Syed Vaisul Karne M (SyvaSoft)

unread,
Jun 17, 2016, 2:57:42 AM6/17/16
to iDempiere
Thanks Red1 :)

Diego Ruiz

unread,
Jun 20, 2016, 10:41:06 AM6/20/16
to iDempiere
Hi Syed, 

thanks a lot for your contribution. I tested and integrated your code to https://bitbucket.org/tbayen_bxservice/org.idempiere.iuimobile.

Kind Regards,
Diego Ruiz

Syed Vaisul Karne M (SyvaSoft)

unread,
Jun 21, 2016, 5:10:31 AM6/21/16
to iDempiere
Hi Diego Ruiz,
It's my pleasure to see my contribution has been accepted.

Kind regards,
Syed. 

redhuan d. oon

unread,
Aug 16, 2016, 9:06:18 AM8/16/16
to iDempiere
Hi Diego Ruiz,
According to https://groups.google.com/forum/#!topic/idempiere/ggAlc_ltpiw the fix may not yet be in binary. Hope you can check and issue the latest binary with that fix.

Carlos Antonio Ruiz Gómez

unread,
Aug 23, 2016, 3:38:56 PM8/23/16
to iDempiere
Hi Syed, analyzed the case you're describing, effectively the patch on MRole could solve the problem, but I think is not correct as is hiding the big issue that the iuimobile really has about context management.

The thing is:
when adding the #AD_Role_ID in the context (WLogin:337) is using a context (i.e. object Properties 185)
But when reading the #AD_Role_ID from the context to populate the client lookup is using a different context object (i.e. ServerContextPropertiesWrapper 223 which leads to ServerContext 233)

I think the iuimobile plugin must correct the context management - the actual implementation seems to be obsolete (inherited from adempiere) and probably is not thread safe.

Regards,

Carlos Ruiz

Syed

unread,
Aug 24, 2016, 9:01:52 AM8/24/16
to iDempiere
Hi Carlos Ruiz,

Thanks a lot for pointing out where the actual problem lies. I will look into iDempiere context management and will simulate the same in iuimobile to overcome this problem.

Regards,
Syed.
Reply all
Reply to author
Forward
0 new messages