All Answers

0 votes

Hi Felix, see below:

1) Application.CurrentCulture is read-only, the comment is wrong. The writing is internal.
It is updated on every incoming request and it sets the current thread CurrentCulture and CurrentUICulture.
The culture set for the current thread is determined as described at the bottom of this page: https://docs.wisej.com/docs/concepts/localization
2) CultureInfo.DefaultThreadCurrentCulture is different it “Gets or sets the default culture for threads in the current application domain.” Which is basically the Application Pool. It’s not useful to change that since different threads may need difference cultures.

If you check Thread.CurrentThread.CurrentCulture it is the same as Application.CurrentCulture, unless the thread is an out-of-bound thread, meaning
it is not created by a request from the client. In .NET the only culture that is used is the CurrentThread.CurrentCulture and for the UI resources is CurrentThread.CurrentUICulture.

Both of those are kept in sync by Wisej when a request comes in and is assigned to a thread.

You can change the culture in many ways:

– Default.json culture property. When “auto”, Wisej recognizes the culture of the Browser: English Browsers will see english formatted dates and numbers while French browsers will se a different formatting.
– You can force the language switch by adding the lang argument to the URL (see docs above). You need a URL reload to swap languages because all widgets have to be recreated.

However, if your pages or windows are localized and have been already created, their language will not change since the resources managed to the controls is created only once at InitializeComponent(). So a language switch will need you to close and recreated windows or pages.

 

  • Luca answered Mar 8, 2017 - 5:27 pm
  • last active Oct 2, 2021 - 10:42 pm
0 votes

Hello Andi,

To add to Frank’s tip to use ?color (see also https://docs.wisej.com/docs/controls/general/icons).

I have tried the same code you posted and it works fine for me, the color changed to red. What build of Wisej are you using? There was a bug about this few builds ago.

Also, when processing CellValueNeeded the caching of the values is up to the code (you). In Virtual mode the datagrid doesn’t store the value of the cells anywhere. So CellValueNeeded is fired every time the grid needs the value of the cell, which can be hundreds or thousands of times. If you create a new style object every time you end up creating a lot of instances that the GC will have to collect at some point.

HTH

 

 

 

  • Luca answered Sep 21, 2017 - 3:34 pm
  • last active Oct 2, 2021 - 10:39 pm
0 votes

Answers below:

Session Timeout

The session timeout set in Default.json is the timeout used to fire OnSessionTimeout. The “real” session timeout set in the cache for the automatic destruction of the session is session-timeout * 2. The SessionTimeout event is not the real timeout, it is not possible to recover a session after the real time out.

The event is not fired after the session timeout, it is fired after the session timeout since the last time any user activity has been detected.

[Edited: the part above is a bit wrong. When user activity is detected, the next session timeout is skipped. The actual firing of the event will occur at session-timeout + residual time from last user activity, or something like that…]

As soon as there is any activity that causes a request, wisej will skip the next session timeout. The reason is that the “real” timeout in the session cache is renewed automatically as soon as the session is retrieved. So a request to the server, any request, renews the session life time. The method Wisej.Core.userIsAlive() is called on mousemove, mousedown and keydown.

Client Side Errors vs Server Side Errors

Wisej.onNetworkError() and Wisej.onException(with ex.invalidSession = true) should be the only errors that cannot be handled by the server.

Otherwise  any call to Wisej.onException() is either from an exception generated on the server, or a bug on the client.

You can handle the application’s exception globally by attaching to:

Application.ThreadException.

The handler and the event args are part of System.Threading. Just by attaching to the event suppresses the default exception dialog.

To show the ajax loader on the client at any time, call Wisej.Core.showLoader(true|false);

HTH

 

 

 

 

  • Luca answered Oct 12, 2017 - 3:43 pm
  • last active Oct 2, 2021 - 10:37 pm
0 votes

The DataGridView cannot know which columns you want to hide when the size of the grid changes and for which device.

Wisej provides a common set of responsive breaks defined in ClientProfiles.json and automatically detects changes according to the rules and fires the ResponsiveProfileChanged event. The event is available on any container (Form, Page, Desktop) and as a static event in Application.ResponsiveProfileChanged.

https://docs.wisej.com/api/wisej.core/general/wisej.core.clientprofile

https://docs.wisej.com/api/wisej.web/general/application/wisej.web.responsiveprofilechangedeventargs

The availability of the event at the Application level allows the programming of application-specific controls that adapt to the client profile. For example, a panel showing customer  information can show more or less information.

This is the built-in ClientProfiles.json:

http://s3.amazonaws.com/wisej/downloads/Examples/ClientProfiles.json

You can override it by placing your ClientProfiles.json in the root of the project.

The breaks are evaluated from the top down, the first match will fire the Application.ResponsiveProfileChanged event. You can also detect a specific device using the userAgent regular expression.

When you handle ResponsiveProfileChanged you can hide, show, resize, position controls or columns. Hidden columns can be shown using the column visibility menu at the top right corner.

  • Luca answered Nov 4, 2017 - 11:44 pm
  • last active Oct 2, 2021 - 10:33 pm
0 votes

Hi Terza,

I think the best way to achieve this is using [WebMethods]. Find more information here:

https://docs.wisej.com/docs/concepts/javascript-object-model

Hope that helps.

Best regards
Frank

  • Frank (ITG) answered Nov 17, 2017 - 10:56 am
  • last active Oct 2, 2021 - 10:28 pm
0 votes

The AllowedFileTypes property is not a regex, it’s a weird IANA Media Types specifications and not all browsers use it correctly.

It’s not a Wisej thing. Uploading of files is entirely in the hands of the browser.

See also:

https://docs.wisej.com/api/wisej.web/content/upload#allowedfiletypes

https://www.w3schools.com/tags/att_input_accept.asp

 

  • Luca answered Dec 1, 2017 - 4:23 pm
  • last active Oct 2, 2021 - 10:28 pm
0 votes

Application.Theme…. methods. For example, Application.Theme.GetColor(“inactiveBorder”).

Another way is Color.FromName(“@inactiveBorder”). Adding the @ prefix to a color or font name means it’s a name defined in the theme. However, in this case the RGB values will be invalid since it’s only used for rendering back to the client.

You can also read icons, fonts, values assigned to specific appearance keys and states.

It’s used in the Wisej.ResponsiveNavigationPanel samples.

Also look for: https://docs.wisej.com/api/wisej.core/general/wisej.core.clienttheme

  • Luca answered Jan 5, 2018 - 1:19 am
  • last active Oct 2, 2021 - 10:25 pm
0 votes
In reply to: RightToLeft Issues

Thank you for the feedback.

RightToLeft is not yet implemented for DataGridViews and ListView and PropertyGrid (all based on DataGridView): https://docs.wisej.com/docs/concepts/righttoleft

  • Luca answered Sep 19, 2017 - 1:40 pm
  • last active Oct 2, 2021 - 10:23 pm
0 votes
In reply to: RightToLeft Issues

Hi

i’m still having problem with the RightToLeft property.

The problematic controls:

*ListView – columns still on the left

*DataGridView – columns still on the left

*MenuBar

*TreeView

I’ve used this tread : https://docs.wisej.com/docs/concepts/righttoleft

without successful.

Thanks for your help.

Orel.

  • Orel Gabay answered Jan 7, 2018 - 10:20 am
  • last active Oct 2, 2021 - 10:22 pm
0 votes
In reply to: User session questions

Find more information here:

Application.SessionCount – Number of active sessions.

HealthCheck.json – Make your Wisej app ready for load balancing (depending on usage of memory, cpu etc.)

Best regards
Frank

  • Frank (ITG) answered Jan 20, 2018 - 1:33 pm
  • last active Oct 2, 2021 - 10:21 pm
0 votes

It’s possible on the client and only if the url of the iframe is from the same origin of the container or the browser blocks all cross-frame javascript.

You can execute javascript in the context of the iframe and retrieve the body element using “this.getBody()” when  this is the iFramePanel widget. You can process the dom elements on the client and fire back events to the server or call a server method marked using [WebMethod].

  • Luca answered Jan 5, 2018 - 2:16 am
  • last active Oct 2, 2021 - 10:14 pm
0 votes

Hi Marcel,

“static” members are shared to all sessions/users/etc. This is an interesting feature when you want a simple way to share information or to “inject” information (information that was made available outside of the current session, say another user sent you a message, or a WebService inserted a new invoice to validate on your work queue).

If you need static objects that are intended to be used only by a given session, you should use session variables. Please have a look at Using the Session Object

  • Tiago (ITG) answered Jan 15, 2018 - 4:06 pm
  • last active Oct 2, 2021 - 10:12 pm
0 votes

Yes, use the StyleSheet component from the toolbox. Drop it on the container at design time and it will add the CssClass property to all controls. You can use it to assign a css class name. You can also type css or assign a css file to the styleSheet component, and/or you can simply add a css file to Default.html.

Or you can target an element using the id, and/or name and class combination using the standard css selection rules.

Another way is to create a new appearance key in a mixin theme file. The new appearance key can inherit from an existing one and then you can change the styles and properties. Most Wisej controls let you change their appearance key.

The Wisej theme system is easier and more flexible than plain css since it also supports properties while css is limited to predefined styles. You can also edit mixin files using the Theme Builder and you can create custom preview js scripts or simply preview and theme your app while running.

CSS gets very messy and very complicated quickly and with a lot of unintended consequences because of style inheritance and selection rules. Wisej generates the css styles on the fly as needed from the theme json definition.

See:

https://docs.wisej.com/theme-builder/

 

  • Luca answered Feb 20, 2018 - 6:05 pm
  • last active Oct 2, 2021 - 10:10 pm
0 votes

In web apps you can get the IP of the client, not the client’s computer name.

But if you get the computer name in your winforms app then you can send it to the wisej app in the browser as a URL argument. You can read the arguments in your Wisej app in two ways:

HTH

 

  • Luca answered Feb 26, 2018 - 5:38 pm
  • last active Oct 2, 2021 - 10:08 pm
0 votes

Hi Rudy,

did you include GridE.js as embedded resource and also enabled the WisejResources attribute ?
See: https://docs.wisej.com/docs/concepts/embedded-resources

Please note that the build in DataGridView of Wisej also supports hierarchical rows.

Hope that helps.

Best regards
Frank

  • Frank (ITG) answered Mar 20, 2018 - 1:16 pm
  • last active Oct 2, 2021 - 10:07 pm
0 votes

Wisej supports the entire .NET Component Model system. You can define TypeConverters and DropDown or Modal editors and even draw a picture into the value cell of the PropertyGrid. You can also differentiate between WinForms editors and Wisej editors by querying for the IWisejEditorService instead of the IWindowsFormsEditorService. The methods of the interface are the same (https://docs.wisej.com/api/wisej.core/interfaces/wisej.core.iwisejeditorservice).

This is a good document from MS: https://msdn.microsoft.com/en-us/library/ms171840.aspx

I will post a sample.

 

  • Luca answered Feb 14, 2018 - 9:14 pm
  • last active Oct 2, 2021 - 10:05 pm
0 votes

Hi Andrew,

Your question

would it be safe to assume that database classes that inherit IDisposable are also disposed in that same cleanup process?

 

Session documentation

If there other objects that are referenced but are not children, they will also be disposed when the GC and their finalizer kicks in.

Although it’s a safe bet, I would use the logger to get the evidence.

 

Back to your comments to Frank’s answer

When a user logs into my app, I store some basic info about who is logged in for that session and also create a database instance and a logging instance to capture basic user activity and any errors.

You can use the Session object like this sample

Snippet

internal static MyPrincipal AppPrincipal
{
    get { return Application.Session.User; }
    set { Application.Session.User = value; }
}
 
internal static MyIdentity CurrentUser
{
    get
    {
        return AppPrincipal.Identity.IsAuthenticated
            ? AppPrincipal.Identity as MyIdentity
            : null;
    }
}
 
internal static string CurrentUserName
{
    get
    {
        return CurrentUser != null
            ? "User: " + CurrentUser.UserName
            : "No user";
    }
}

replacing MyPrincipal and MyIdentity with your own classes of course. You can also store the database connection object on a session object. That way, it will be forgotten (and disposed if IDisposable is implemented) when the session expires. The same goes for the logger object, unless you prefer to use s static object that lives accross all sessions.

  • Tiago (ITG) answered Mar 12, 2018 - 10:27 am
  • last active Oct 2, 2021 - 10:04 pm
0 votes

It was working without a json file because of a bug causing Wisej to revert to Default.json in case the URL page didn’t have a corresponding json configuration. It was fixed with:

WJ-8854: Self hosting in single exe defaults to Default.json when the configuration file is not present on disk.

What was happening in your app is that when you navigate to /userlogin.html Wisej used Default.json because it couldn’t find UserLogin.json so it treated /userlogin.html as if it was a child application when it may not have been what the developer intended. It could have been simply an html page. The result was that /userlogin.html started a new session and called the entry point defined in Default.json. In fact if you navigate back to / it also created a new session, which is correct but for child applications. See https://docs.wisej.com/docs/concepts/configuration at the top and last entry. I think we should add an entry for child applications.

In a nutshell, Wisej supports child applications (aka multiple entry points) within the same project. If you were using this feature but without the correct configuration. If you simply add UserLogin.json it will start working again exactly as before. But you can decide the entry point class name and method and you can use “pretty url” like simply /userlogin. However, remember that whenever the URL changes it’s a new session. To keep the same session you can use either a url parameter or a hash value.

HTH

 

 

  • Luca answered Apr 10, 2018 - 3:13 pm
  • last active Oct 2, 2021 - 10:02 pm
0 votes

Hi David,

Thank you for the test case. The issue with your code is that the thread is out of context. There is no way for a thread on the server to know the session that started it unless you pass it to the thread start method, etc.

That’s why we have Application.RunInContext(), Application.StartTask, and Application.Update().  See https://docs.wisej.com/docs/concepts/background-tasks.

When adding Application.Update(this) at the end of your thread method the update works, but it has nothing to update since the code before (adding the panel) couldn’t flag the component as needing an update since the code before the update is running out of context. It can still access all the components, since Wisej components can run in the thread, but the session is not reachable.

To make it short :), this is how to fix your test code: two different ways:

  1. Instead of new Thread(thread), use Application.StartTask(thread). This is the easiest, since Application.StartTask() starts the thread in context.
  2. You can use new Thread(thread), but in the thread() method, wrap the code in Application.Update().
 Application.Update(this, () =>
 {
   Panel p2 = new Panel();
   p2.BackColor = Color.Green;
   p2.Location = new Point(50, 50);
   Controls.Add(p2);
 });

Also, as I mentioned before, you don’t need to use this.Invoke((Action)delegate(){}). It doesn’t do anything with Wisej, it simply calls the delegate.

I also noticed that your Web.config is coming from a mistaken template that we have distributed during the beta. Please change the json handler in Web.config to:

<add name=”json” verb=”*” path=”*.json” type=”System.Web.HttpForbiddenHandler” />

The handler is not necessary at all. However, we thought that some apps may store sensitive information in the configuration json and this setting prevents someone from downloading the json. The mistaken handler we had did exactly the opposite.

HTH

Best,

Luca

 

  • Luca answered Nov 4, 2016 - 3:13 pm
  • last active Oct 2, 2021 - 10:00 pm
0 votes

I can’t find the previous question about the UserPopup. IIRC you were asking about the placement properties.

This is how it works:

  • The UserPopup is a UserControl that you can design as any container, with the difference that it is shown using ShowPoup() https://docs.wisej.com/api/wisej.web/containers/wisej.web.userpopup#showpopup-opener-onclose. The ShowPoup() method shows the panel at the specified x,y location *or* links the popup to the opener control specified in the call.
  • When ShowPopup(opener) is called, the popup is located on the screen in relation to the opener using the Alignment and PlacementModeX/Y properties. It’s like the combobox dropdown but you can also decided if it pops above, left, right, below and if it aligns to the left, middle, right, etc.
  • The system takes care of adjusting the popup location in case it doesn’t fit.
  • Once the popup is visible it will move together with the opener in case the form is moved.

The popup closes automatically when the user clicks outside of the popup or a control outside is activated. You can also close it by calling Close(). The Closed even fires when the popup is closed.

It’s a useful control to create complex input widgets, especially if used in conjunction with the tool icons that all input controls accept.

HTH

Best,

Luca

  • Luca answered Nov 1, 2016 - 5:10 pm
  • last active Oct 2, 2021 - 9:59 pm
Showing 3261 - 3280 of 11k results