We are working to make our application as accessible as possible. We need to allow customers to keep their hands on the keyboard and tab all the way through the application. We are using angular-ui/bootstrap horizontal navset tabs to display and collect data within each tab-panel. Currently we cannot find a non-mouse way to get focus from the tabs down into the tab-panel to allow focus on select-able components.
Is the tabset built for view-only content? If not, how do we get focus down to editable / select-able components in the tab-panels?
HTML:
<tabset>
<tab tab-index=1>
<tab-heading>
<span>hello</span><em>1</em>
</tab-heading>
One
<input type="button" value="test" tabindex="2">
</tab>
<tab heading="Two" tab-index=1>Two</tab>
<tab heading="Three" tab-index=1>Three</tab>
</tabset>
JS:
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('test', function ($scope) {
});
Related
I am creating a dropdown in XUL like this:
<button id="bid" oncommand="alert(event.target.nodeName)" >
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</button>
I want to alert the value of nodeitem which is being clicked. Using event.target.nodeName giving nodeName as menuitem but using nodeValue is retuning undefined as it starts to take value of button node. How can I get the value of the menuitem clicked. I also tried $(this).val() but even that gave undefined. Using $(this).attr('value')
also didn't help. I can put oncommand for menuitem but that doesn't seem to be actual solution. Is that the only way or some method exist to get the value?
The XUL code you have in the question is non-functional. Either you should be using a <menulist> instead of a <button>, or your <button> needs the property type="menu" or type="menu-button". If you are going to use a <button> without the type="menu" property, you would actually have to open a popup in the command event handler for the <button> and then select from there. That does not appear to be what you are wanting. It is, however, quite doable. I use a construction like that in one of my add-ons, except I have it open when one of several <label> items is clicked. This allows re-use of a single <menupopup> for multiple different items in the window. In that case, the <menupopup> is a rather large amount XUL code that I did not want to repeat and maintain multiple duplicates in the XUL for the window.
The value of the <menuitem> selected:
Your actual question is how to get the value of the <menuitem> selected by the user. All of the code below is tested and functional. As you can see from the code you can get the value of the <menuitem> you select (at the time of selection) from: event.target.value.
Using a <menulist> element:
The most common element to use would be a <menulist>. This would normally be used when you are having the user select from multiple options a choice that is going to be remembered and used later, or used to adjust what is presented in the user interface. It would generally not be used to select from multiple immediate actions (which are acted upon and the choice not remembered). A <menulist> is what is used in the examples for <menuitem> and <menupopup> on MDN.
<menulist id="bid2" oncommand="alert(event.target.value)" >
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</menulist>
The above code will give you what looks like a button with a selection of <menuitem> entries when you click on it. It will alert with the value of the <menuitem> you have selected.
This will produce an item that looks like:
Which you can click on to open a drop-down list:
If you select an item:
You will get an alert:
And the object will then show your selection:
Using a <button> element:
It is also possible to use a <button> element with the property type="menu" or type="menu-button" specified. However, this provides no visual feedback to the user as to which option is currently selected. [Note: Your JavaScript could manually change the <button> label property to provide this feedback.] You could use this type of element if it is button that produces an immediate action rather than a selection that is remembered.
The code:
<button type="menu" id="bid2" label="A Button" oncommand="alert(event.target.value)">
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</button>
This will produce an item that looks like:
Which you can click on to open a drop-down list:
If you select an item:
You will get an alert:
And the object will then NOT show your selection:
If you want to set the label of the <button> to reflect the selection made by the user, you could use:
<button type="menu" id="bid2" label="A Button" oncommand="event.target.parentElement.parentElement.label=event.target.value;alert(event.target.value)">
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</button>
When three is selected, that will result in a button that looks like:
Using a <toolbarbutton>:
You could, alternately, use a <toolbarbutton>.
When not hovered, doing so would look like:
When hovered:
When open for selection:
Choices in UI design:
There are many choices that you have to make when designing your user interface. There are many different ways to get to the same effective result, with somewhat different look and feel. You really should be trying these types of options on your own. You may find the XULRunner program XUL Explorer to be of use when prototyping XUL.
Selecting UI elements and a look and feel is, in my opinion, beyond the scope of questions on stackoverflow. While you probably won't get specific XUL help, you can ask UI design questions at: the User Experience stack exchange.
I got a simple login form. I am using <p:ajax> to invoke a <p:blockUI> (see this question).
<h:commandButton id="anmeldung_button"
action="#{benutzerAnmeldung.anmelden}" value="Anmelden"
styleClass="btn btn-info btn-sm">
<p:ajax process="#form" update="#form"/>
</h:commandButton>
<p:blockUI id="block" block=":anmeldung" trigger="anmeldung_button" />
I am using <o:highlight /> to highlight invalid inputs. This works fine.
It is working with a <f:ajax> perfectly, too.
Apperently, it is not working with <p:ajax>.
How can I achieve this?
This is caused by <p:ajax> trying to refocus the active element after executing the oncomplete scripts via doEval() (as can be seen in handleReFocus() function in core.ajax.js script. However, when you submit the form by clicking the command button instead of pressing Enter while inside the input, then that active element becomes the command button itself, not the input text. You can confirm this by just using Enter key to submit the form. You'll see that the focus is done right.
There are in your particular case 2 ways to workaround this:
Make use of PrimeFaces' own autofocus facility via <p:focus> which is placed inside the form as below:
<h:form id="anmeldung">
<p:focus context="anmeldung" />
...
</h:form>
It also automatically takes into account invalidated input fields.
Set PrimeFaces.customFocus to true in JavaScript, so that handleReFocus() function won't do its job.
<script>PrimeFaces.customFocus = true;</script>
I am using Primefaces 5.1 and I have a dashboard where I can drop components onto it.
But, when I drop a component on I want a different component to be rendered.
Here is my dashboard, and the panel component that is cloned and dropped onto the dashboard.
<p:dashboard id="board" model="#{dashboardBean.model}" binding="#{dashboardBean.dashboard}">
<p:ajax event="reorder" listener="#{dashboardBean.handleReorder}" update="msgs" />
</p:dashboard>
<p:panel id="draggable">
<h:outputLabel value="Drag Panel Into Dashboard"></h:outputLabel>
</p:panel>
<p:draggable for="draggable" helper="clone" dashboard="board"/>
Now I can trigger a capture the 'reorder' event and change the 'model' to replace it with the correct component on the java side. But the Dashboard does not get re-rendered at this point.
I can add a command button to trigger the re-render...
<h:commandButton value="Refresh" action="#{dashboardManagedBean.refreshChart}"/>
But I want this to happen automatically.
Can anyone offer some advice please.
(comment promoted to answer)
What if you referesh the component from handleReorder() using this RequestContext.getCurrentInstance().update("foo:bar")?
I need to refresh page in include tag, but this is load dynamically using forEach property, this is a fragment of my code:
<button onClick="... refresh include page ..."/>
<tabbox id="tb" orient="vertical" >
<tabs>
<tab forEach="${vm.columnList}" label="${each}" hflex="true"/>
</tabs>
<tabpanels>
<tabpanel forEach="${vm.columnList}" >
<include height="90%" rc="/Campaigns.zul" rca="${each}" date="${vm.date}" />
</tabpanel>
</tabpanels>
</tabbox>
I want that when the button is pressed, the page that is in the include will reload, not whole page. Try using an id to use invalidate function, but using the forEach property to load the page gave an error with repeated id.
The page is loaded using forEach because depending of the parameter that is passed the content is different and different tabs are generated.
In the onClick of the button try this
<button onClick="tb.getSelectedPanel().getFirstChild().invalidate()" />
I am stuck over a problem While dealing with primefaces charts.
Problem
When I click on a lineChart, a dialogue should appear which contains another linechart.
Sample Code
<p:lineChart id="chartOne" rendered="cond1"/>
<p:dialog widgetVar="dialogOne">
<p:lineChart id="chartTwo" rendered="cond1"/>
</p:dialog>
<script>
$('#chartOne').bind('jqplotClick',
function (ev, seriesIndex, pointIndex, data) {
dialogOne.show();
}
);
</script>
Now I am able to display dialogue on chart click but chart inside dialogue is not refreshing. I don't know much about refreshing content through JavaScript function.
Update1:
Condition is: chartOne should provide click over its whole canvas(not only datapoints or series). chartTwo should be rendered only if dialogOne.show() happens.
Any help...Much appreciated
It might be a solution to use a dynamic dialog.
From the documentation:
Dynamic mode allows dialog to fetch it's contents beforeit's shown rather than on page load which is useful to reduce initial page load times. Default is false.
Just define your dialog like this:
<p:dialog widgetVar="dialogOne" dynamic="true">
Update:
To refresh the dialog from Javascript you can use p:remoteCommand. Example:
<h:form id="formId">
<p:dialog id="dialog" />
</h:form>
<p:remoteCommand name="updateDialog" update=":formId:dialog"/>
Second update:
To use the p:remoteCommand call updateDialog() from Javascript.
Try this:
<p:lineChart id="chartOne" rendered="cond1" >
<p:ajax event="itemSelect" listener="#{bean.action}" update="chartTwo" oncomplete="dialogOne.show()" />
</p:lineChart>
<p:dialog widgetVar="dialogOne">
<p:lineChart id="chartTwo" rendered="cond1"/>
</p:dialog>
on the method action() of your backing bean, you should ready the data for chartTwo.
The clickable part of the chart, as per the user manual, would be the series, not the entire chart. check
http://www.primefaces.org/showcase-labs/ui/interactiveCharts.jsf
for more information and a working example.