Eclipse/UiBinder won't recognize RadioButton, and I feel like I have tried everything to get it to work.
I have added the import at the top, that isn't recognized(even though RadioButton should be in the client UI bundle, that is imported by default as far as I can tell, and I have tried writing the tag in every conceivable way, but Eclipse still says:
Attribute RadioButton has no value.
The thing that really gets me is that I added the UiField in the Java parent file, and it imported just fine. I'm about to de-evolve into an ancestor made of pure anger as the project hinges on me figuring this out.
I appreciate any help that may be given. Here is my code:
DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"
ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:gwt="urn:import:com.google.gwt.user.client.ui.RadioButton"
<g:HTMLPanel>
<g:Label ui:field="label">Starting Text</g:Label>
<g:VerticalPanel>
<gwt: RadioButton ui:field="radio2" ui:name="radio">Option2</gwt:RadioButton>
<g: RadioButton ui:field="radio3" value="value1" name="radio">Option3</g:>
<gwt: RadioButton ui:field="radio4" name="radio"/>
<ui: RadioButton ui:field="radio5" name="radio">Option5</ui:>
</g:VerticalPanel>
</g:HTMLPanel>
The correct way to use RadioButton is this:
<g:RadioButton ui:field="radio" name="radio">Option 1</g:RadioButton>
The reason for the error, by the way, is the space before RadioButton. It makes it an attribute instead of a part of a tag.
Related
<g:TabBar ui:field="mainTabPanel" />
<g:DeckPanel ui:field="mainDeckPanel" >
<g:Label text="test"/>
</g:DeckPanel>
Only TabBar got visible, DeckPanel shows nothing.
Is it cos DeckPanel only works in Quirks Mode?
The Gwt Doc doesn't say anything about which browser mode DeckPanel support.
I changed to DeckLayoutPanel <g:DeckLayoutPanel ui:field="mainDeckPanel" >... but nothing happened.
I found the answer, just 1 line of code
mainDeckPanel.showWidget(0);
And i done
I am new to GWT and can not find an answer to this: I have got a nice UIBinder for a TextBox, it works, I have UIHandler working with it, ok. But what if I want to show a value from this TextBox all over my HTML? Is there a way to declare one variable to reuse this value all over HTML, or should i declare new Label with new ui:field name every time I want to show the value on one html page, and fill every such a Label with UIHandler (wich I could do right away, but this seems really boring)?
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<g:TextBox ui:field="myField"/><br/>
<div>
<p>
What do I need to put here if i want to see **myField.getValue()** in html, may be even multiple times?
And **here**?
I want to avoid creation of new and new objects in back-end class for just one value, multiple labels here are ok. How to push one value in all of them, when myField content is changed?
</p>
</div>
</g:HTMLPanel>
There are two approaches to designing GUI in code in MVC (whatever that means) way:
GUI is smart and pulls data from model, usually when certain events happen (data binding falls into this category),
GUI is stupid, so the data is pushed into view by a controller (it is sometimes called a passive view).
Both have their pros and their cons, but the important thing is: when you try to combine them, the pros cancel each other, and cons - accumulate. That is you end up with disadvantages of each pattern and a big mess.
UIbinder is a tool that helps you build a stupid view, as used in MVP pattern. It helps you easily create a bunch of objects that will redraw parts of view when you push data into them. They are not supposed to be intelligent entities. So the boring way seems to be the way to go.
Not wanting to use a label is, btw, a little strange: you need an object to update parts of the ui (it's Java, using objects is what we do!). It just so happens that such type of object exists and is called Label. Would you like it more if the very same class was called AnAutomaticHtmlUpdaterThatRequiresNoLabelWhatsoever?
Hi I am new to GWT MVP pattern. I am from asp.net background and currently I am working on GWT and I am asked to create a Master page which has the menu items which should be in common to all the views. Initially I created a sample mvp project using https://developers.google.com/web-toolkit/articles/mvp-architecture-2 and in that there is navigation from one view to another. How do I maintain one view constant and keep changing the other views depending on what menu item we click. Please help
The article you mentioned is from before MVP support added in GWT. It's good at explaining the concept, but the actual implementation is less useful. To continue take a look at the GWT documentation about activities: https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces . There you will also find the solution for your problem. In brief, take a look at the ActivityManager. This manages all activities. On the activity manager you set one widget that will be static for all activities. This widget must have a method setWidget (actually it must implement AcceptsOneWidget). In each of your activity implementations you get this widget via the start method. And by calling setWidget with the specific view for that activity in the start method you set the activity specific view. This is all described very briefly, but you should get the concept if you read the mentioned documentation.
If you are working with UiBinder, your ui.xml file should be like this,
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
</ui:style>
<g:DockLayoutPanel unit="EM">
<g:north size="4">
//Add Logo, menus or what you want to be displayed for all the pages
</g:north>
<g:center>
//Add code for your desired UI. In java code you change the UI by this "flowpanel"
For eg: <g:FlowPanel ui:field="flowpanel" />
</g:center>
</g:DockLayoutPanel>
Then everytime you can clear and add the widgets to be displayed in the view in the <g:center> using your java code like this flowpanel.clear();
flowpanel.add(anyWidget you need).
So <g:north> will be static view and <g:center> will be dynamic view. Now you will get the page as you desired. Since you can change everytime your view on <g:center> only.
Like this you can add <g:east>, <g:west> and g:south> if required.
If you are not working with UiBinder then do everything in your java code as follows,
final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Style.Unit.EM);
dockLayoutPanel.addNorth(any widget you need, "4"); //NorthPanel
dockLayoutPanel.add(any widget you need); //CenterPanel
Where "4" is the size of the panel, you can change it.
Like this dockLayoutPanel.addWest(any widget you need, "4"); //WestPanel
dockLayoutPanel.addEast(any widget you need, "4");//EastPanel
dockLayoutPanel.addSouth(any widget you need, "4"); //SouthPanel
I hope you got idea now.
You divide your screen into two or more areas, and assign dedicated ActivityMapper and ActivityManager to each zone. For example, one zone can be "menu" with MenuActivityManager, and the other zone "body" with BodyActivityManager.
Here is a good explanation:
http://blog.ltgt.net/gwt-21-activities-nesting-yagni/
Note that there are both pros and cons for using this method. Browsers take milliseconds to render standard html. It may be easier to create a widget mainMenu and include it (best of all, using UiBinder) into every view, rather than deal with two activity managers.
I am trying to use Twitter Bootstrap for GWT and get the same nice and pretty view like the showcase here and here is what I did:
1- downloaded the module from git
2- run package task in the pom.xml
3- included the created jar in my projects classpath.
4- inherited the module in my project.gwt.xml file with
<inherits name="com.github.nyao.bootstrap4gwt.Bootstrap"/>
5- included the module in my root xml
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:m='urn:import:com.clouway.exreport.client.accountcreation.view'
xmlns:t='urn:import:com.github.nyao.bootstrap4gwt.client.ui'
>
<ui:style src="newRegistrationStyle.css"/>
<g:HTMLPanel addStyleDependentNames="{style.mainPanel}">
<div class="{style.headdistance}"/>
<div class="{style.container}">
<g:DecoratorPanel addStyleDependentNames="{style.decoratorPanel}">
<g:VerticalPanel addStyleDependentNames="{style.verticalPanel}}">
<m:AccountEditor ui:field="accountEditor"/>
<!--<g:Button ui:field="create" text="create"/>-->
<t:Button type="Success" text="sing in"/>
<g:Label ui:field="errorsLabel"/>
...
</ui:UiBinder>
But nothing happened. I got normal text box and normal button.
I took a look at this tutorial which is very good and the guy got the things right, his application has very nice look. I took a look at his code but didn't find any reason why my look i still normal and he got the nice view. thanks for help in advance
Instead of using bootstrap4gwt try using gwtbootstrap which is far better and has much more components compared to the former. The forum is also very active in gwtbootstrap.
I have a problem with navigation too right now. I have 2 dataTables, one is located within a regular facelets-page, the other one is located in a dialog.
Both have the same code:
<p:commandButton
value="Show car"
ajax="false"
action="showCar?faces-redirect=true">
<f:setPropertyActionListener value="#{car}" target="#{carBean.car}" />
</p:commandButton>
I also tried adding process="#this" without success.
The problem is, while the navigation works for the commandButton inside the facelets-page, it doesnt work for the button inside the dialog. It seems that the current page is reloaded after the click.
Replacing it with a doesn't help either.
Has anybody experienced something like this before? Could this be an issue with the dialog?
Thanks and best regards,
Robert
Forget my previous answer, I didn't read your question carefully. What might be happening is a failure in your <f:setPropertyActionListener> call. If it is (silently) failing then the error will cause JSF to automatically navigate back to the same page.
Add this to your page somewhere so you can see any helpful error FacesMessages that may be provided by the framework:
<p:messages
id="messagesForDebugging"
showDetail="true"
autoUpdate="true" />
The autoUpdate will cause it flash up messages generated by global Ajax requests.
You may also want to put a logging statement in your carBean.setCar() method to make sure that it is successfully setting the value. If it is failing then maybe you need to provide a custom converter for Car values?