[
http://jira.jboss.com/jira/browse/JBSEAM-1124?page=all ]
Arjan van Bentem updated JBSEAM-1124:
-------------------------------------
Description:
Neither LocaleSelector nor ThemeSelector currently provide a method
valueChanged(ValueChangeEvent event). Such method is needed to get some auto-submit
without the need for a lot of JavaScript, to change the locale or theme without clicking a
Submit button. The following would create a dropdown list, for which selecting a new value
would change the look and feel right away -- thus loosing any changes made in other forms
on the very same page...
<h:form>
<h:selectOneMenu
immediate="true"
value="#{themeSelector.theme}"
onchange="submit();"
valueChangeListener="#{themeSelector.valueChanged}">
<f:selectItems value="#{themeSelector.themes}" />
</h:selectOneMenu>
</h:form>
And while extending ThemeSelector, why not add a method selectTheme(String), just like
LocaleSelector#selectLanguage(String).
And one might also make the cookie name available for injection. This, however, also needs
some work in the
xmlns:theme="http://jboss.com/products/seam/theme" namespace.
http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/...
public class ThemeSelector extends Selector
{
:
:
private String cookieName = "org.jboss.seam.core.Theme";
public String getCookieName() {
return cookieName;
}
public void setCookieName(String cookieName) {
this.cookieName = cookieName;
}
/**
* Sets the theme and forces it to load, useful for auto-submit dropdown
* lists using the JavaScript onchange event: <br>
* <code>
* <h:form>
* <h:selectOneMenu
* immediate="true"
* value="#{themeSelector.theme}"
* onchange="submit();"
* valueChangeListener="#{themeSelector.valueChanged}">
* <f:selectItems value="#{themeSelector.themes}"
/>
* </h:selectOneMenu>
* </h:form>
* </code>
*
* @param event
* the JavaServer Faces ValueChangedEvent
*/
public void valueChanged(ValueChangeEvent event) {
setTheme((String) event.getNewValue());
select();
}
/**
* Sets the theme and force it to load, useful for quick action links: <br>
* <code>
* <h:commandLink
value="#{messages['org.jboss.seam.theme.default']}"
*
action="#{themeSelector.selectTheme('default')}"/>
* </code>
*
* @param theme the name of the theme to be loaded
*/
public void selectTheme(String theme) {
setTheme(theme);
select();
}
:
}
In fact, the current LocaleSelector somehow does support the auto-submit without any
chances:
<h:form>
<h:selectOneMenu
value="#{localeSelector.localeString}"
onchange="submit();"
valueChangeListener="#{localeSelector.select}">
<f:selectItems value="#{localeSelector.supportedLocales}" />
</h:selectOneMenu>
</h:form>
However, I guess this works by accident; in fact
org.jboss.seam.core.LocaleSelector#select() does not accept ValueChangeEvent as a
parameter; so I don't know why the above works -- no guarantees for future releases of
JavaServer Faces? So for LocaleSelector as well a method valueChanged(ValueChangeEvent
event) could be added, just to be sure:
http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/...
public class LocaleSelector extends Selector
{
:
:
/**
* Sets the locale and forces it to load, useful for auto-submit dropdown
* lists using the JavaScript onchange event: <br>
* <code>
* <h:form>
* <h:selectOneMenu
* immediate="true"
* value="#{localeSelector.localeString}"
* onchange="submit();"
* valueChangeListener="#{localeSelector.valueChanged}">
* <f:selectItems
value="#{localeSelector.supportedLocales}" />
* </h:selectOneMenu>
* </h:form>
* </code>
*
* @param event
* the JavaServer Faces ValueChangedEvent
*/
public void valueChanged(ValueChangeEvent event) {
select();
}
:
}
That's all...!
Arjan.
was:
Neither LocaleSelector nor ThemeSelector currently provide a method
valueChanged(ValueChangeEvent event). Such method is needed to get some auto-submit
without the need for a lot of JavaScript, to change the locale or theme without clicking a
Submit button. The following would create a dropdown list, for which selecting a new value
would change the look and feel right away -- thus loosing any changes made in other forms
on the very same page...
<h:form>
<h:selectOneMenu
immediate="true"
value="#{themeSelector.theme}"
onchange="submit();"
valueChangeListener="#{themeSelector.valueChanged}">
<f:selectItems value="#{themeSelector.themes}" />
</h:selectOneMenu>
</h:form>
And while extending ThemeSelector, why not add a method selectTheme(String), just like
LocaleSelector#selectLanguage(String).
And one might also make the cookie name available for injection. This, however, also needs
some work in the
xmlns:theme="http://jboss.com/products/seam/theme" namespace.
http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/...
public class ThemeSelector extends Selector
{
:
:
private String cookieName = "org.jboss.seam.core.Theme";
public String getCookieName() {
return cookieName;
}
public void setCookieName(String cookieName) {
this.cookieName = cookieName;
}
/**
* Sets the theme and forces it to load, useful for auto-submit dropdown
* lists using the JavaScript onchange event: <br>
* <code>
* <h:form>
* <h:selectOneMenu
* immediate="true"
* value="#{themeSelector.theme}"
* onchange="submit();"
* valueChangeListener="#{themeSelector.valueChanged}">
* <f:selectItems value="#{themeSelector.themes}"
/>
* </h:selectOneMenu>
* </h:form>
* </code>
*
* @param event
* the JavaServer Faces ValueChangedEvent
*/
public void valueChanged(ValueChangeEvent event) {
setTheme((String) event.getNewValue());
select();
}
/**
* Sets the theme and force it to load, useful for quick action links: <br>
* <code>
* <h:commandLink
value="#{messages['org.jboss.seam.theme.default']}"
*
action="#{themeSelector.selectTheme('default')}"/>
* </code>
*
* @param theme the name of the theme to be loaded
*/
public void selectTheme(String theme) {
setTheme(theme);
select();
}
:
}
In fact, the current LocaleSelector somehow does support the auto-submit without any
chances:
<h:form>
<h:selectOneMenu
value="#{localeSelector.localeString}"
onchange="submit();"
valueChangeListener="#{localeSelector.select}">
<f:selectItems value="#{localeSelector.supportedLocales}" />
</h:selectOneMenu>
</h:form>
However, I guess this works by accident; in fact
org.jboss.seam.core.LocaleSelector#select() does not accept ValueChangeEvent as a
parameter; so I don't know why the above works -- no guarantees for future releases of
JavaServer Faces? So for LocaleSelector as well a method valueChanged(ValueChangeEvent
event) could be added, just to be sure:
http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/...
public class LocaleSelector extends Selector
{
:
:
/**
* Sets the locale and forces it to load, useful for auto-submit dropdown
* lists using the JavaScript onchange event: <br>
* <code>
* <h:form>
* <h:selectOneMenu
* immediate="true"
* value="#{localeSelector.localeString}"
* onchange="submit();"
* valueChangeListener="#{localeSelector.valueChanged}">
* <f:selectItems value="#{localeSelector.themes}"
/>
* </h:selectOneMenu>
* </h:form>
* </code>
*
* @param event
* the JavaServer Faces ValueChangedEvent
*/
public void valueChanged(ValueChangeEvent event) {
select();
}
:
}
That's all...!
Arjan.
Fixed typo in Javadoc: #{localeSelector.supportedLocales} instead of
#{localeSelector.themes}
Make ThemeSelector and LocaleSelector implement
valueChanged(ValueChangeEvent event), and some more...
------------------------------------------------------------------------------------------------------
Key: JBSEAM-1124
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1124
Project: JBoss Seam
Issue Type: Feature Request
Components: Framework
Affects Versions: 1.2.1.GA
Environment: All
Reporter: Arjan van Bentem
Priority: Optional
Neither LocaleSelector nor ThemeSelector currently provide a method
valueChanged(ValueChangeEvent event). Such method is needed to get some auto-submit
without the need for a lot of JavaScript, to change the locale or theme without clicking a
Submit button. The following would create a dropdown list, for which selecting a new value
would change the look and feel right away -- thus loosing any changes made in other forms
on the very same page...
<h:form>
<h:selectOneMenu
immediate="true"
value="#{themeSelector.theme}"
onchange="submit();"
valueChangeListener="#{themeSelector.valueChanged}">
<f:selectItems value="#{themeSelector.themes}" />
</h:selectOneMenu>
</h:form>
And while extending ThemeSelector, why not add a method selectTheme(String), just like
LocaleSelector#selectLanguage(String).
And one might also make the cookie name available for injection. This, however, also
needs some work in the
xmlns:theme="http://jboss.com/products/seam/theme"
namespace.
http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/...
public class ThemeSelector extends Selector
{
:
:
private String cookieName = "org.jboss.seam.core.Theme";
public String getCookieName() {
return cookieName;
}
public void setCookieName(String cookieName) {
this.cookieName = cookieName;
}
/**
* Sets the theme and forces it to load, useful for auto-submit dropdown
* lists using the JavaScript onchange event: <br>
* <code>
* <h:form>
* <h:selectOneMenu
* immediate="true"
* value="#{themeSelector.theme}"
* onchange="submit();"
* valueChangeListener="#{themeSelector.valueChanged}">
* <f:selectItems value="#{themeSelector.themes}"
/>
* </h:selectOneMenu>
* </h:form>
* </code>
*
* @param event
* the JavaServer Faces ValueChangedEvent
*/
public void valueChanged(ValueChangeEvent event) {
setTheme((String) event.getNewValue());
select();
}
/**
* Sets the theme and force it to load, useful for quick action links:
<br>
* <code>
* <h:commandLink
value="#{messages['org.jboss.seam.theme.default']}"
*
action="#{themeSelector.selectTheme('default')}"/>
* </code>
*
* @param theme the name of the theme to be loaded
*/
public void selectTheme(String theme) {
setTheme(theme);
select();
}
:
}
In fact, the current LocaleSelector somehow does support the auto-submit without any
chances:
<h:form>
<h:selectOneMenu
value="#{localeSelector.localeString}"
onchange="submit();"
valueChangeListener="#{localeSelector.select}">
<f:selectItems value="#{localeSelector.supportedLocales}" />
</h:selectOneMenu>
</h:form>
However, I guess this works by accident; in fact
org.jboss.seam.core.LocaleSelector#select() does not accept ValueChangeEvent as a
parameter; so I don't know why the above works -- no guarantees for future releases of
JavaServer Faces? So for LocaleSelector as well a method valueChanged(ValueChangeEvent
event) could be added, just to be sure:
http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/...
public class LocaleSelector extends Selector
{
:
:
/**
* Sets the locale and forces it to load, useful for auto-submit dropdown
* lists using the JavaScript onchange event: <br>
* <code>
* <h:form>
* <h:selectOneMenu
* immediate="true"
* value="#{localeSelector.localeString}"
* onchange="submit();"
*
valueChangeListener="#{localeSelector.valueChanged}">
* <f:selectItems
value="#{localeSelector.supportedLocales}" />
* </h:selectOneMenu>
* </h:form>
* </code>
*
* @param event
* the JavaServer Faces ValueChangedEvent
*/
public void valueChanged(ValueChangeEvent event) {
select();
}
:
}
That's all...!
Arjan.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira