GWT : How to Read Hidden Box value? - gwt

I Have a hidden box in my HTML. How I can get it value in my GWT when onModuleLoad??
the hidden box will content a value pass from another page. Now I can see the hidden box content the value but I fail to get the value in my GWT onModuleLoad.
HTML page:
<%
String sSessionID=request.getParameter("NA_SessionID");
if(sSessionID==null)
session.setAttribute("NetAdminSession",(String)session.getAttribute("NetAdminSession"));
else
session.setAttribute("NetAdminSession",sSessionID);
%>
<form name=frmMain method=post>
<input type=hidden name=NA_SessionID name=NA_SessionID value="<%=(String)session.getAttribute("NetAdminSession")%>"></input>
</form>

You can access any element in the DOM by using the GWT DOM Class. For example, if your hidden box has the id "NetAdminSession", you may use the following to access the hidden box...
DOM.getElementById("NetAdminSession");

To: Geoffrey Wiseman
my HTML file is in the GWT HTML.. but I change it to JSP file instead of HTML
To: prometheus
Thanks you information, I will give it a try now.

I'm not sure what your overall approach/architecture is, but it might also be helpful to look into some of the new features added in GWT 2.0. Specifically, Declarative Layout with UIBinder. With this you can actually construct your user interface with declarative XML instead of using pure Java. I would steer away from creating too much of your UI in the actual HTML file since it will be easier to control those UI elements if you construct them in your GWT code. You can still stick to good MVC principles if you break your classes/code up the right way.

Related

Wagtail. Ability to edit html within editor

My editors want to have an ability to edit raw html within editor.
For example, we can have simple list markup:
<ul>
<li>Some text<li>
</ul>
Or with custom classes and event tags:
<ul>
<li class="my_class">Some text
<span class="special">Some additional info</span>
<li>
</ul>
And so on.
I know that built-in Draftail doesnt support html editing.
But using third-party editor comes with problem:
Losing integration with system. For example, i cant just put image like with draftail. Or, preview mode cant handle all functionality of third-party editor.
So, maybe someone has working solution for this situation.
I thought about using special StreamField panels, but it seems to be overhead of blocks. Dont like this idea of having lots of blocks with little differences
Wagtail does not support raw HTML editing within the page editor out of the box intentionally. The philosophy (zen) of Wagtail is to help editors and developers 'wear the right hat' when working in Wagtail.
HTML editing is usually best provided to developers, where there is an expected knowledge of what is required for things like accessibility, security and the benefit of tooling (like git).
However, if HTML editing is a must, you will probably need to build your own editor field for that purpose or find a suitable package that works with HTML markup such as django-markupfield. Adding image/snippet/page chooser functionality however will have to be built for whatever you end up using. You may also want to look at the Wagtail markdown package either as an alternative to HTML or a starting point, it allows for a syntax of linking to pages/images.
Wagtail lets you use any kind of Django field or widget with the FieldPanel.
Please ensure you consider all the risks when implementing this feature, such as accessible HTML (e.g. heading levels), security (disallow some tags such as script tags), malformed HTML leaking into the rendered template and of course the end user experience.
At the end i made my own solution
Simple rewrite some methods in wagtail`s Html DbWhiteLister and HtmlConverter.
This gives me an opportunity to allow any tags with any attributes.
https://github.com/Chenger1/wagtailtinymce.-Full-Rich-Text-Editor

how to disable browser autofill username and password. we are using Gwt MVP model for creating screen and using Sencha GXT library

we have autocomplete="off" in jquery but not finding to set in gwt xml file.Can someone help me to set autocomplete to false.
<f:FieldLabel labelSeparator="" ui:field="userNameLabel">
<f:widget><f:TextField width="300" ui:field="userName" /></f:widget>
</f:FieldLabel>
Textfield doesn't have autocomplete attribute to set.
What ui library are you using?
For example if you are using vanilla gwt you could get the Element and set the attribute autocomplete="off" manually
http://www.gwtproject.org/javadoc/latest/com/google/gwt/dom/client/Element.html#setAttribute-java.lang.String-java.lang.String-
You could create a Composite that wraps the field and set this automatically, then create instances of TextFieldNotAutocomplete for example
http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/Composite.html

keycloak translation / message with link should open in new Tab

I would like to have a translation in my messages_en.properties containing a link, which opens in a new tab. Is there a way to do this?
I already tried to add
<a target="_blank" href="http://example.com">Example</a>
and
<a href="#" onclick='window.open("http://example.com");return false;'>Example</a>
without success.
Thanks in advance
Most likely your HTML isn't working because of kcSanitize in the template file. Wherever HTML messages are allowed, Keycloak's FreeMarker templates will also wrap the text with this method which:
Allows sanitizing of html that uses Freemarker ?no_esc. This way, html
can be allowed but it is still cleaned up for safety. Tags and
attributes deemed unsafe will be stripped out.
The no_esc allows HTML to render (by not being escaped) but the kcSanitize strips unsafe tags and attributes first. In my testing, I found that "target" and "onclick" are stripped out.
One way that works but that I wouldn't recommend for safety is removing the kcSanitize() around where your message displays in the corresponding .ftl file.
Another idea is adding an id or class to the element in your .properties file and using custom Javascript to set the target="_blank" attribute.

Integrate Htmls into GWT

We have a web application that its UI is based on GWT.
We are pretty satisfied from the technology, but we have one major problem: We get html files from our designer, and it takes a lot of time to integrate them into our GWT code.
Is there a quick way or rules to do that?
For instance, I would like to take the html, put it almost "as is" in a ui.xml file, and then start binding the components to UiBinder fields.
What is the quickest way to do that? What should I do with the CSS and JS files that I get?
I need some guidelines to make this conversion, so it will be quick & easy.
We have the same problem. It might be hard for a designer to get used to GWT widgets. But he'll have to forget about making HTML proof-of-concepts and using GWT directly.
We didn't overcame the difficulty. As a result, many GWT features are under-used (like CSSResources, or GWT-Bootstrap layout capabilities).
I would advise to have him learn the xml of GWT widget libraries.
You can also start by using GWT Designer. This way he can still do the design, learn the XML bit by bit, and you can still work on wiring the components.
Of course it is a slow process. People don't change old habits instantly.
Errai seems to fit your requirements.
Basically is uses regular HTML5 templates, binded to GWT logic.
"Create standard conform HTML5 templates or use existing HTML and CSS files to design your web and mobile applications."
http://errai.github.io/
Here is an example of a sign-in page:
<!DOCTYPE html>
<link rel=stylesheet href="css/TodoList.css">
<div data-field="main">
<h1>Get it done with Errai.</h1>
<div class=form>
<p class=error data-field=loginError>
Login failed. Please check that your email address and password were entered correctly.
</p>
<input type=text data-field=username placeholder="Email">
<input type=password data-field=password placeholder="Password">
<button data-field=loginButton>Sign In</button>
<p>New here? Sign up in seconds!</p>
</div>
</div>
source
(p.s. I've never used it, yet)

HTML Page with GWT

is it possible to have parts (instead of the entire page) of an HTML page written with GWT?
Is it usual?
I'm quite new to GWT and trying to understand the workflow of it.
Thanks.
I meant HTML static pages, written by hand (or any other means) and on these pages have parts (forms, media, whatever...) in GWT.
Yes, the simplest way this can be achieved is setting an id attribute on the elements you want to be filled in by GWT, e.g.
<body>
<div>
...
<div id="myId"></div>
</div>
</body>
, and then using
RootPanel myIdPanel = RootPanel.get("myId");
so you can put any GWT contents into myIdPanel.
Note, that there are many more ways to mix HTML that's generated by GWT and by other means - basically any combination is possible.
You might want to check out their UIBinder approach:
http://www.gwtproject.org/doc/latest/DevGuideUiBinder.html