how to render react-toolbox menu - react-toolbox

How does one render a react-toolbox Menu component? There are no examples in the documentation. Or, rather, the example uses the IconMenu wrapper, which is unusable if you need to pass in the active property.
When I render a Menu, it is always rendered as active, regardless of the active property. It could be a css problem, but I'm unable to follow how IconMenu applies css, and it's interactions with ThemeProvider.

Related

How does Component.setVisible() method work?

I have some experience with GWT . In GWT , widget.setVisible() method will add style="display:none" style to widget. But component of vaadin wouldn't . I checked with firebug , I can't see my component while set component's visible to false. Why ?
I think that should be also have hidden style instead of not containing. I reallize that vaadin's codes were server side. But sometimes , if I would like to just hidden (set style display to none) , has there anyway to accomplish this instead of using css ?
I don't understand concept of what different between without adding component and setVisible(false) ?
As you already noticed, an invisible component is not transferred from server to browser, and from browser's point of view the component doesn't exist. This approach has to benefits:
Less data to transfer from server to client
Security: User cannot inspect invisible components' generated HTML with tools like Firebug because those doesn't exist on the browser.
So basically from browser's point of view it's the same thing that you don't add it to the UI at all. But usually it's just easier to toggle component's visibility instead of adding and removing it from its parent.
If you want to hide components with CSS, you can do it by defining your own theme and adding a style for that there. Then just apply the style for the component you want to hide by using the addStyleName method.
SETVISIBLE Sets the visibility of the component.
Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.
So as the documentation says invisible components are not not visible.

Deciding between NgComponent and NgDirective

Is there some rule of thumb to be followed while deciding to implement custom element as NgComponent or NgDirective?
What are the issues to keep in mind while deciding to choose either of them?
If you want to add functionality/behavior to existing tags/elements you use a directive (like ng-class or ng-hide).
You can apply a directive to different tags.
To create a new element/tag you create a component (like accordion, carousel, modal, ...).
A component is a new custom element that can have a template that defines its shadow DOM content.
You can use a directive to dynamically add/remove html content too, but with a component you can create new elements that have a clear boundary between inside and outside.
A component has it's own scope that is not part of the application scope hierarchy.
You can't easily reach inside a components content.
Html generated from a directive is like any other html tags. You have transclusion with components (I think someone is working on components without shadow DOM and transclusion like in Angular.js but I don't know how far this is and how this will look like.)
You can use directives inside a component, and a component inside a component.

embedding a FMX forms

There is some code regarding embedding a FMX form into a panel...
http://docwiki.embarcadero.com/CodeExamples/XE5/en/FMXEmbeddedForm_(Delphi)
....I want to embed multiple forms into the same panel, closing the prior
one of course. I'm having an issue with the proper to close./free those
forms when using the method to embed them from that docwiki.
from testing I have found that the form is not actually embedded but that the objects on the form are moved onto a new parent simulating the effects of an embedded form.
In the vcl this was pretty easy to do but in dmx it's a different ball game.
Any thoughts?
The easiest method to do this is to put a transparent layout on each form as top level component.
When you need to embed a form in your panel, just create an instance of your form and change the parent of it's layout to your panel.
When you don't need the embedded form, you can reparent the layout to its form and free it.
When you embed a form you are, as you state, reparenting some of the components from the embedded form onto the containing form.
If you want to remove those components you can either:
reparent them to something other than the containing form (e.g. back to their original form). Do this if you have multiple forms which you want to be able to swap in and out without having to destroy and recreate all the time.
Free the embedded form (use DisposeOf under ARC). This will both destroy the form and it's controls and remove them from the containing form. (Note that while the containing form becomes the Parent, the original, embedded form stays as the Owner. This the controls are destroyed when the embedded form is destroyed.
You can then create and reparent another form in it's place.
Also note that you can safely embed multiple forms onto one container form but you will need to use a different object as a container for each one. You can also put multiple components or sets of components onto an embeddable form and embed them into separate locations on a container form or even onto multiple forms.
However you can only embed each control(s) into one form at a time.

Rails - How do I create a checkbox that will render a different form when checked without refreshing?

As the title suggests, I am wondering how to create a checkbox on a view that will change what form is rendered without refreshing the page.
In my app/views/home/ folder I have _form_1.html.erb and _form_2.html.erb.
I want to default to <%= render 'form_1' %> when the box is not checked, and change to <%= render 'form_2' %> when the box is checked.
I've attempted to look up how to do this, but things like .is(":checked") and check_box_tag don't seem to be working for me, or I'm using them wrong.
Any help is appreciated!
EDIT: I am using Rails 3.2.12 and Ruby 1.9.3.
The way I'd do this is to render both the form partials from another view, and put each of them in a div. The default form div should be visible, and the optional form div should be hidden. Then you can toggle the display of the divs with a click action on the checkbox.
Depending on what's in the forms and how they interact with your controller, there's likely a lot of other work involved in processing, but in order to toggle the displayed forms, the method above is one option.
If you want to do this without a refresh you'll have to use javascript. What you'd do is render each form but as hidden. This next part is really easy with jquery. When a checkobox is selected you'd just do something like $('#form1').show(), and conversely $('#form2').hide()

xxforms:tree view of xforms:select1 control

I am trying to display items retrieved from an XML DB using xforms:select1 control using appearance=xxforms:tree. The items appear collapsed or expanded automatically and the behaviour is not the same for all the items retrieved. I have the following questions regarding xxforms:tree view:
how to make sure this view shows sub-nodes (those expandable/collapsable using +/- icon) as collapsed or expanded always, irrespective of, for example, the no. of nodes covered by the + icon?
how to render select1 with tree appearance without making any of the items hyperlinks?
how to make sure no item is highlighted/selected by default?
...and although the docs say xxforms:menu is also a possible appearance (URL http://www.orbeon.com/orbeon/doc/reference-xforms-extensions#tree), the details are not available...
About which branches of the tree should be open — By default all the nodes leading to selected nodes are open, this so the selected values are all visible. But you can change this default behavior and specify which nodes should be open using the xxforms:open attribute. For more on this, see the section "Controlling which tree nodes are initially open" on Selection Controls. Note that this feature was added in October 2010, so it is not included in Orbeon Forms 3.8, and until Orbeon Forms 3.9 is released, you'll need to get a nightly build for this.
About using links in the tree — At this point, the nodes you can click on in the select1 appearance="xxforms:tree control are rendered as links, so users know that this is something they can click on to make a selection. I assume that you don't want them to show as links because the tree might be "read-only" in your case (for information only, not to make a selection). This isn' supported at this point. As a workaround, you could use CSS to change the pointer and appearance of links in the tree so to users they don't even notice that this those are links.
About the menu appearance — It works very much like the tree appearance. See for instance this example using the menu.

Resources