Skip to main content

Form buttons not working

5 replies [Last post]
beagle2
Offline
Joined: 2006-02-19

Has anyone ever experienced a problem with buttons on forms not working when using using a WebBrowser? They press the button and nothing happens. This is for all buttons.

I've had a few people report this problem. I'm thinking it may be something specific on their PCs as doesn't seem to be a widespread problem, but I've no idea what it might be.

Any ideas?

Beagle

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
uta
Offline
Joined: 2007-01-10

It seems strange, but could you try to rewrite the method of [i]WebBrowser[/i] as
[b]protected boolean willOpenURL(URL url) { return true; }[/b]
The default implementation is [b]
protected boolean willOpenURL(URL url) {
if (null == url)
return true;

WebBrowserUtil.trace("URL = " + url.toString());
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkConnect(url.getHost(), url.getPort());
}
catch (AccessControlException e){
return false;
}
}
return true;
}[/b]

If there is a security problem the button press does not initiate navigation.

beagle2
Offline
Joined: 2006-02-19

I managed to get to the bottom of it! In Internet Explorer there's this security message "When you send information to the Internet, it might be possible for others to see that information." when you submit forms, it was this that was blocking the submit button on the forms from working in the embedded browser, but it wouldn't display the security message.

When my program starts I now check the HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\ registry entry and if it's not equal to "0x0" then I display a warning message saying the submit buttons will no work, and they need to open IE and ensure the 'In future, do not show this message' is selected.

Hope this helps someone else...

leiffrederiksen
Offline
Joined: 2008-01-09

I have problems checking and setting values in the registry in a Vista environment with UAC. What method do you use to check the registry entry?

madroadie
Offline
Joined: 2006-04-20

Programs can not Write to the HCLM in Vista if the User is not running with local admin Privileges.

private static final String WIN_VISTA = "Windows Vista";

/**
* Vista detection method.
* @return True if the system is running Windows Vista.
*/
public static boolean isWindowsVista()
{
String os = System.getProperty("os.name");

if (os != null && os.startsWith(XSystemHelper.WIN_VISTA))
return true;

return false;
}

Next you need to see if the user is Running with Admin Privileges, I created a navtive interfaces for this.. I'll spare you most of details and just give you the C++ You need put in your dll.

/*
* Class: com_mycompany_xjava_service_ntservice_NTServiceApi
* Method: isNTAdminAdministrator
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_com_mycompany_xjava_service_ntservice_NTServiceApi_isNTAdminAdministrator
(JNIEnv * env, jobject javaclass)
{
const int INFOBUFFERSIZE = 1024;
BOOL bIsAdmin = FALSE;
HANDLE hProcess, hAccessToken;
UCHAR InfoBuffer[INFOBUFFERSIZE];
PTOKEN_GROUPS ptgGroups = (PTOKEN_GROUPS)InfoBuffer;
DWORD dwInfoBufferSize;
PSID psidAdministrators;
SID_IDENTIFIER_AUTHORITY siaNTAuthority = SECURITY_NT_AUTHORITY;
UINT uCount;

hProcess = GetCurrentProcess();

if(!OpenProcessToken(hProcess, TOKEN_READ, &hAccessToken))
return JNI_FALSE;

bIsAdmin = GetTokenInformation(hAccessToken, TokenGroups, InfoBuffer, INFOBUFFERSIZE, &dwInfoBufferSize);
CloseHandle(hAccessToken);

if (!bIsAdmin)
return JNI_FALSE;

if( !AllocateAndInitializeSid(&siaNTAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,

0, 0, 0, 0, 0, 0, &psidAdministrators))
{
return JNI_FALSE;
}

bIsAdmin = FALSE;
for (uCount = 0; uCount < ptgGroups->GroupCount; uCount++)
{
if (EqualSid(psidAdministrators, ptgGroups->Groups[uCount].Sid))
{
bIsAdmin = TRUE;
break;
}
}

FreeSid(psidAdministrators);
return bIsAdmin ? JNI_TRUE : JNI_FALSE;
}

Madroadie

beagle2
Offline
Joined: 2006-02-19

Someone else has just contact me with this problem again. Does anyone have any ideas what it might be? I've asked them to try disabling their firewall and anti-virus software but that didn't rectify the problem.