Toggle images using ajax - jsf

I have 4 buttons, each button will display one image using Ajax.
<h:form>
<h:commandButton value="Click" action="#{userAjaxData.toggleStatus}">
<f:ajax render="Family" />
</h:commandButton>
<h:commandButton value="Click" action="#{userAjaxData.toggleStatus}">
<f:ajax render="Karam"/>
</h:commandButton>
<h:commandButton value="Click" action="#{userAjaxData.toggleStatus}">
<f:ajax render="Memo"/>
</h:commandButton>
<h:commandButton value="Click" action="#{userAjaxData.toggleStatus}">
<f:ajax render="Baba"/>
</h:commandButton>
<h:panelGroup id="Family">
<p:graphicImage library="images/img" name="family.png" id="FamilyImg" rendered="#{userAjaxData.status}"/>
</h:panelGroup>
<h:panelGroup id="Karam">
<p:graphicImage library="images/img" name="Karam.png" id="KaramImg" rendered="#{userAjaxData.status}"/>
</h:panelGroup>
<h:panelGroup id="Memo">
<p:graphicImage library="images/img" name="memo.png" id="MemoImg" rendered="#{userAjaxData.status}"/>
</h:panelGroup>
<h:panelGroup id="Baba">
<p:graphicImage library="images/img" name="baba.png" id="BabaImg" rendered="#{userAjaxData.status}"/>
</h:panelGroup>
</h:form>
My manged bean:
#ManagedBean(name = "userAjaxData", eager = true)
#SessionScoped
public class UserAjaxData implements Serializable {
private static final long serialVersionUID = 1L;
private boolean status = false;
public void toggleStatus() {
status = true;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}}
when I click any button It will display the related image, so if I click the first one it will display the first image, and the second button will display the second image but the first image will not removed. I just need one way to display one image each time I click button. so if I click the first button then the second button should the second image displayed and the first one disappear.
How can I mange it?

If your usecase is really that simple, I would recommend using only one always rendered <h:graphicImage /> (no need for PrimeFaces GraphicImage in this case) and set the appropriate image to show in the backing bean via ajax instead of one or multiple toggle statuses with something like this:
<h:form id="form">
<h:commandButton
id="familyButton"
action="#{toggleImageView.setImage('family.png')}"
value="Family"
>
<f:ajax render="image" />
</h:commandButton>
<h:commandButton
id="karamButton"
action="#{toggleImageView.setImage('karam.png')}"
value="Karam"
>
<f:ajax render="image" />
</h:commandButton>
<h:commandButton
id="memoButton"
action="#{toggleImageView.setImage('memo.png')}"
value="Memo"
>
<f:ajax render="image" />
</h:commandButton>
<h:commandButton
id="babaButton"
action="#{toggleImageView.setImage('baba.png')}"
value="Baba"
>
<f:ajax render="image" />
</h:commandButton>
<br />
<h:graphicImage
id="image"
library="image/img"
name="#{toggleImageView.image}"
/>
</h:form>
#ManagedBean
#RequestScoped
public class ToggleImageView {
private String image;
#PostConstruct
public void initialize() {
image = "family.png";
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
}
Just adapt to your needs.

Related

jsf input form value disapear on first submit

I use JSF 2.2 and Primefaces 6.1. I have a problem with textarea value on first form submit. I use multiple subviews for one form. The problem is when type something into textarea, after first form submit this value disapear and not update data model. But when type again and fire submit, then this value is showing. The textarea is inside subTable in dataTable.
I tried use valueChangeListener together with ajax. This works, but when click to fast to submit, then value haven't be updated. I tried only ajax but result was the same. I tried valueChangeLister with onchange="submit()" but this not worked. tried solution Primefaces valueChangeListener or <p:ajax listener not firing for p:selectOneMenu but this not working
Textarea code
<h:form id="reuestForm">
<div class="form-group">
<p:dataTable id="edScopeTable" styleClass="form-group dataTable-space"
value="#{requestBean.employeeDealerTabController.getEdScopeCategories()}"
var="category">
<p:columnGroup type="header">
<p:row>
<p:column headerText="#{i18nMsg.ed_env_scopes_tbl_colScope_header}"/>
<p:column headerText="#{i18nMsg.ed_env_scopes_tbl_col_openIdConnect_header}"/>
<p:column headerText="#{i18nMsg.ed_env_scopes_tbl_col_reasonNeeded}"/>
</p:row>
</p:columnGroup>
<p:subTable
value="#{requestBean.employeeDealerTabController.getScopeReasonsByCategory(category)}"
var="edScope" rendered="#{requestBean.employeeDealerTabController.isCategoryInTable(category)}">
<p:column styleClass="#{requestBean.employeeDealerTabController.calculateDiff(edScope,'cell-right')} textAlign-center">
<p:inputTextarea id="reason"
value="#{edScope.reason}" rows="2"
autoResize="false"
data-disable-type="custom"
styleClass="form-control #{edScope.getDiffValue('reason')}"
rendered="#{edScope.edScopeConst.reasonNeeded}"
label="#{i18nMsg.edScope_request_selectionTable_scope_reasonNeeded} #{edScope.edScopeConst.name}"
disabled="#{requestBean.employeeDealerTabController.disableReasonField()}">
<f:attribute name="scope" value="#{edScope}"/>
<f:validateBean
binding="#{requestBean.validatorContainer.requiredBeanValidator}"/>
<p:message for="reason" display="tooltip"/>
</p:inputTextarea>
<h:outputText
rendered="#{not edScope.edScopeConst.reasonNeeded}"
value="#{i18nMsg.edScope_request_selectionTable_scope_noReasonNeeded}"/>
</p:column>
</p:subTable>
</p:dataTable>
</div>
<div class="text-right">
<p:commandButton value="#{(requestBean.request.version eq 1 and requestBean.request.stateDraft) or requestBean.isEdRequestToBePrinted() ? i18nMsg.general_mainButton_send_and_print : i18nMsg.general_mainButton_send}"
id="send"
update="requestForm"
actionListener="#{requestBean.prepareDialog()}"
oncomplete="args.validationFailed ? PF('validationFailedMessageDialog').show() : PF('readyToSendDialog').show(); jQuery(document).scrollTop(0)"
title="#{requestBean.sendButtonDisabled ? i18nMsg.request_sendButtonTooltip : ''}"
styleClass="ui-priority-primary" icon="ui-icon-mail-closed"
disabled="#{requestBean.sendButtonDisabled}" data-disable-type="custom" />
</div>
</h:form>
RequestBean
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean
#ViewScoped
public class RequestBean extends PageBeanBase implements Serializable {
private EmployeeDealerTabController employeeDealerTabController;
#PostConstruct
public void initialize() {
employeeDealerTabController = new EmployeeDealerTabController();
}
public EmployeeDealerTabController getEmployeeDealerTabController() {
return employeeDealerTabController;
}
public void prepareDialog() {
// preparation before send and show dialog with confirmation send form
}
// rest of method
}
EmployerDealerTabController
public List<EdScopeREason> getScopeReasonsByCategory(int category) {
if(category == 1) {
return scopesOidcList;
} else {
return scopesIdentityList;
}
}
EdScopeReason
#Entity
#Table(name = "ED_SCOPE_REASON")
public class EdScopeReason extends InlineDiffBase<EdScopeReason> implements EdScopeConstBearer, Serializable, Comparable<EdScopeReason> {
private String reason;
#Basic
#Column(name = "REASON")
#NotBlank(groups = RequiredValidationGroup.class, message = "{iamat.validation.general.edScopeReason.notempty}")
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
I have setter and getter method. When I debug this value is pass to validator but not set to component. I'm little confused why this value is not set on the first time
EDIT
I add jsf ajax to textarea input and set 5s delay on commandButton. This is some kind of workaround, but still look for better solution. When I use primefaces ajax I don't need delay, but for every primefaces ajax I display loader.gif.
<p:inputTextarea id="reason"
...{requestBean.employeeDealerTabController.disableReasonField()}">
<f:attribute name="scope" value="#{edScope}"/>
<f:validateBean
binding="#{requestBean.validatorContainer.requiredBeanValidator}"/>
<p:message for="reason" display="tooltip"/>
<f:ajax />
</p:inputTextarea>
....
<p:commandButton value="#{(requestBean.request.version eq 1 and requestBean.request.stateDraft) or requestBean.isEdRequestToBePrinted() ? i18nMsg.general_mainButton_send_and_print : i18nMsg.general_mainButton_send}"
id="send"
update="requestForm"
actionListener="#{requestBean.prepareDialog()}"
oncomplete="args.validationFailed ? PF('validationFailedMessageDialog').show() : PF('readyToSendDialog').show(); jQuery(document).scrollTop(0)"
title="#{requestBean.sendButtonDisabled ? i18nMsg.request_sendButtonTooltip : ''}"
styleClass="ui-priority-primary" icon="ui-icon-mail-closed"
disabled="#{requestBean.sendButtonDisabled}" data-disable-type="custom" delay="5000" />

ViewScoped bean recreated instead of calling form action

I have a managed bean, which is ViewScoped. In this bean I need to send a form (using h:commandButton).
This works fine, except when I change my dropdown menu entry (which fires an event and update the page).
After changing the dropdown menu's value, submitting the form recreate the bean (and skips the action associated with the h:commandButton).
Here's my XML:
<rich:panel styleClass="panel_grid_center fifty_percent"
header="Bid matrix">
<!-- display in case the user is not an admin -->
<h:panelGroup rendered="#{not loginBean.isAdmin}">
<h:outputText
value="You do not have sufficient permission to view this page." />
<br />
<h:form>
<h:commandLink action="index.xhtml"
value="Click here to go back to login page / search page." />
</h:form>
</h:panelGroup>
<!-- display if the user is an admin -->
<h:panelGroup rendered="#{loginBean.isAdmin}" id="bid_matrices_panel">
<h:panelGrid columns="2">
<!-- customer group panel -->
<rich:panel styleClass="contained_width fifty_percent"
header="Customer group">
<h:form>
<h:selectOneMenu
valueChangeListener="#{adminBean.onCustomerGroupChangeListener}"
value="#{adminBean.customerGroupService.displayCustomerGroup.spendMinimum}">
<f:selectItems
value="#{adminBean.customerGroupService.customerGroups}"
var="group" itemLabel="#{group.customerGroupLabel}"
itemValue="#{group.spendMinimum}" />
<a4j:ajax event="valueChange" execute="#this"
render="bid_matrices_panel" />
</h:selectOneMenu>
</h:form>
</rich:panel>
<!-- repeatables -->
<rich:panel styleClass="contained_width fifty_percent"
header="Repeatables">
</rich:panel>
</h:panelGrid>
<h:form>
<!-- we loop on each different commoditization (or however that's spelled) -->
<a4j:repeat var="bidmatrix_by_commoditization"
value="#{adminBean.bidMatrices}">
<rich:dataTable styleClass="contained_width"
value="#{bidmatrix_by_commoditization.bidMatricesByCoreStatus}"
var="matrix_by_core_status">
<!-- Display core status -->
<rich:column>
<f:facet name="header">
<h:outputText
value="#{bidmatrix_by_commoditization.commoditization}" />
</f:facet>
<h:outputText value="#{matrix_by_core_status.coreStatus}" />
</rich:column>
<!-- the percentages -->
<c:forEach var="index" begin="0"
end="#{adminBean.columnsNumber - 1}">
<rich:column>
<f:facet name="header">
<h:outputText value="#{adminBean.columnsHeaders[index]}" />
</f:facet>
<h:inputText
value="#{matrix_by_core_status.bidMatrices[index].percentage}">
<f:convertNumber type="percent" />
</h:inputText>
</rich:column>
</c:forEach>
</rich:dataTable>
</a4j:repeat>
<br />
<!-- update matrix button -->
<h:commandButton value="Update" action="#{adminBean.update}" />
</h:form>
</h:panelGroup>
</rich:panel>
My bean:
#ManagedBean(name = "adminBean")
#ViewScoped
public class AdminBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5917562235108703019L;
private CustomerGroupService customerGroupService;
private BidMatrixDao bidMatrixDao;
private List<BidMatricesByCommoditization> bidMatrices;
#PostConstruct
public void init() {
customerGroupService = new CustomerGroupService();
bidMatrixDao = new BidMatrixDaoImpl();
bidMatrices = bidMatrixDao.getBidMatricesByCustomerGroup(customerGroupService.getDisplayCustomerGroup());
}
public void onCustomerGroupChangeListener(ValueChangeEvent v) {
customerGroupService.setDisplayCustomerGroup((BigDecimal) v.getNewValue());
bidMatrices = bidMatrixDao.getBidMatricesByCustomerGroup(customerGroupService.getDisplayCustomerGroup());
}
public CustomerGroupService getCustomerGroupService() {
return customerGroupService;
}
/**
* #param customerGroupService
* the customerGroupService to set
*/
public void setCustomerGroupService(CustomerGroupService customerGroupService) {
this.customerGroupService = customerGroupService;
}
/**
* #return the bidMatrices
*/
public List<BidMatricesByCommoditization> getBidMatrices() {
return bidMatrices;
}
/**
* #param bidMatrices
* the bidMatrices to set
*/
public void setBidMatrices(List<BidMatricesByCommoditization> bidMatrices) {
this.bidMatrices = bidMatrices;
}
public int getColumnsNumber() {
return bidMatrices.get(0).getColumns();
}
public List<String> getColumnsHeaders() {
return bidMatrixDao.getAlignments();
}
public void update() {
bidMatrixDao.updateBidMatrices(bidMatrices);
}
}
Note that I correctly import ViewScoped from javax.faces.bean.ViewScoped;
I also removed the getters/setters from my bean but they are there.
As I said, the form works fine when submitted without changing the h:selectOneMenu value.
Thank you !
Edit: I'm using jsf 2.2 (mojarra), richfaces 4.1, with wildfly 10.1
I fixed this by moving the id used in my ajax directive:
<a4j:ajax event="valueChange" execute="#this" render="bid_matrices_panel" />
I originally put the id in the parent panelGroup, like this:
<h:panelGroup rendered="#{loginBean.isAdmin}" id="bid_matrices_panel">
By creating a rich:panel around the part I actually want to rerender, my problem is fixed:
<h:form>
<rich:panel id="bid_matrices_panel">
<! -- my data to render -->
</rich:panel>
<h:commandButton value="Update" action="#{adminBean.update}" />
</h:form>
I guess re-rendering the form was the source of the issue.
Pretty sure I tried that before, but at that time I also had forgotten to implements Serializable on my AdminBean...

p:inputTextarea returns empty string

I have a p:inputTextarea and I need the value of it while processing the form. It turned out that every time I submit the form I get all the values except the one from the textarea. #{xyzUI.description} is a String object with regular getters and setters.
<ui:composition>
<h:form id="form1">
<p:panel rendered="...">
<p:panel id="formPanel">
<p:panelGrid columns="2" cellpadding="5">
<!-- other form elements -->
<p:outputLabel>Description:</p:outputLabel>
<p:inputTextarea value="#{xyzUI.description}" style="width: 350px;" counter="display" counterTemplate="{0} characters remaining" maxlength="2000" autoResize="true" rows="4" />
<h:panelGroup />
<h:outputText id="display" />
</p:panelGrid>
<p:commandButton rendered="#{not xyzUI.noChange}" action="#{xyzUI.submitForm}" update="formPanel" ajax="true" value="Apply" >
<p:ajax update="formPanel"></p:ajax>
</p:commandButton>
</p:panel>
</p:panel>
</h:form>
<ui:composition>
In my backing bean the value is always "". I don't know what's wrong.
public void submitForm()
{
...
tmp.setDescription(description); // String is always "" while debugging
myList.add(tmp);
RequestContext.getCurrentInstance().update("content");
}
I ran your code locally and discovered the issue. In the command button, remove the p:ajax call.
PrimeFaces command buttons are ajax enabled by default.
So change this:
<p:commandButton rendered="#{not xyzUI.noChange}" action="#{xyzUI.submitForm}" update="formPanel" ajax="true" value="Apply" >
<p:ajax update="formPanel"></p:ajax>
</p:commandButton>
To this:
<p:commandButton rendered="#{not xyzUI.noChange}" action="#{xyzUI.submitForm}" update="formPanel" value="Apply" />
My backing bean for reference
#ManagedBean
#ViewScoped
public class xyzUI implements Serializable{
private static final long serialVersionUID = 6259024062406526022L;
private String description;
private boolean noChange = false;
public xyzUI(){
}
public void submitForm(){
System.out.println(description);
}
public boolean isNoChange() {
return noChange;
}
public void setNoChange(boolean noChange) {
this.noChange = noChange;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

How to remove a row <h:datatable> programmatically

I have a form like the following picture.
In the above picture you can see a green add button. When I click on it, it create a new row in a datatable via send a <f:ajax> to backing bean and render <h:datatable>.
Until now all thing is good. But i Except when I click on a cross button inside of each row, that row removed. but it have a bug. for example when I click on the third row cross button, it removes this row from backing bean but not from my ui.
in the following you can see my backing bean and .xhtml file.
#ManagedBean(name = "AddPollContorler")
#ViewScoped
public class AddPollControl {
private List<Answer> answers = new ArrayList<Answer>();
#PostConstruct
public void init(){
answers.add(new Answer());
answers.add(new Answer());
}
public List<Answer> getAnswers() {
return answers;
}
public void setAnswers(List<Answer> answers) {
this.answers = answers;
}
public void addAnswer() {
answers.add(new Answer());
}
public void removeAnswer() {
String index=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("index");
if (StringUtil.isNumber(index))
answers.remove(Integer.parseInt(index));
}
}
.xhtml :
<div class="panel panel-success rgt">
<div class="panel-heading rgt">
<div style="float: left;">
<h:commandLink styleClass="btn btn-success table-button" action="#{AddPollContorler.addAnswer}">
<h:graphicImage library="img" name="add.png" styleClass=" table-icon" />
<f:ajax execute="answers" render="answers"></f:ajax>
</h:commandLink>
</div>
<h4><h:outputText value="#{msg['protected.poll.add.answers']}"/></h4>
</div>
<div class="form-margin">
<h:dataTable value="#{AddPollContorler.answers}" var="answer" id="answers" style="width:100%;">
<h:column >
<div class="input-group poll-answer" style="margin: 5px;">
<span class="input-group-addon no-left-radius"><h:outputText value="#{CounterControler.index+1}" /></span>
<h:inputText value="#{answer.text}" styleClass="form-control no-radius"/>
<div class="input-group-addon no-right-radius poll-answer-remove" >
<h:commandLink action="#{AddPollContorler.removeAnswer}">
<h:graphicImage library="img" name="cross.png" />
<f:param name="index" value="#{CounterControler.last}" />
<f:ajax render="answers answers" />
</h:commandLink>
</div>
</div>
</h:column>
</h:dataTable>
</div>
</div>
update: 2013/06/12
#ManagedBean(name="CounterControler")
public class CounterControl {
private int index=0;
public int getIndex(){
return index++;
}
public int getLast(){
return index-1;
}
}
your code does look pretty good already. How does the CounterControler internally work? (no source given) Alternatives to send the current object might be
to give the object directly as the parameter (you need a fitting converter for that),
give it as direct parameter (action="#{AddPollContorler.removeAnswer(answer)}, works from EL 2.2 on), or
directly get the current object out of the given ActionEvent
The last point would look like
xhtml
<h:commandLink action="#{AddPollContorler.removeAnswer}">
<h:graphicImage library="img" name="cross.png" />
<f:ajax render="answers" />
</h:commandLink>
managed bean
public void removeAnswer(ActionEvent ev) {
Answer selectedItem = null;
try {
UIDataTable objHtmlDataTable = retrieveDataTable(
(UIComponent)ev.getSource());
selectedItem = (Answer) objHtmlDataTable.getRowData();
answers.remove(answer);
} catch (NullPointerException e) {
// somehow couldn't find the element
}
}
private static UIDataTable retrieveDataTable(UIComponent component) {
if (component instanceof UIDataTable) {
return (UIDataTable) component;
}
if (component.getParent() == null) {
return null;
}
return retrieveDataTable(component.getParent());
}
I like that one because it takes most logic out of the frontend. Hope you get your rows cleaned with one of that tactics.
Also, you only need to mention answers once in <f:ajax render="answers" />
EDIT: Even I don't know why - wrapping a <h:panelGroup layout="block" id=" answersWrapper"> around the <h:dataTable> and rendering that panelGroup worked for me.
<h:form id="myForm">
<h:panelGroup id="answerWrapper" layout="block">
<rich:dataTable value="#{myTestBean.answers}" var="answer" id="answers">
<h:column >
<h:outputText value="#{answer}"/>
<h:commandButton id="button" action="#{myTestBean.doTheAction}">
<f:ajax render=":myForm:answerWrapper" />
</h:commandButton>
</h:column>
</rich:dataTable>
</h:panelGroup>
</h:form>

JSF update inputText after selectOneMenu choice

I want to change the inputTexts' values when I choose another Skin from my selectOneMenu.
Everything is doing well, my Converter gives back the right Object from the menu, but the inputTexts are not updated.
<h:form>
<h:selectOneMenu id="dropdownSkin"
value="#{helloBean.currentSkin}" defaultLabel="Select a skin.."
valueChangeListener="#{helloBean.skinValueChanged}" immediate="true"
onchange="this.form.submit()" converter="SkinConverter" >
<f:selectItems value="#{helloBean.mySkinsSI}" var="c"
itemValue="#{c.value}" />
</h:selectOneMenu>
<br />
<h:inputText id="name" value="#{helloBean.currentSkin.title}"></h:inputText>
<br />
<h:inputText id="tcolor" value="#{helloBean.currentSkin.titleBar.textColor}"></h:inputText>
<br />
<h:inputText id="bcolor" value="#{helloBean.currentSkin.titleBar.backgroundColorStart}"></h:inputText>
</h:form>
Here is what my Bean looks like. I debugged it and the Object currentSkin is set correctly. Now i need to know how to update the textfields content.
#ManagedBean
#SessionScoped
public class HelloBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<ExtendedSkin> mySkins;
private List<SelectItem> mySkinsSI;
private ExtendedSkin currentSkin;
public void skinValueChanged(ValueChangeEvent e) {
currentSkin = (ExtendedSkin) e.getNewValue();
FacesContext.getCurrentInstance().renderResponse();
}
public List<ExtendedSkin> getMySkins() {
mySkins = XMLParser.readExtendedSkins();
return mySkins;
}
public List<SelectItem> getMySkinsSI() {
mySkinsSI = new LinkedList<SelectItem>();
for (ExtendedSkin s : getMySkins()) {
mySkinsSI.add(new SelectItem(s, s.getTitle()));
}
return mySkinsSI;
}
public void setMySkinsSI(List<SelectItem> myItems) {
this.mySkinsSI = myItems;
}
public ExtendedSkin getCurrentSkin() {
if (currentSkin == null) {
currentSkin = getMySkins().get(0);
}
return currentSkin;
}
public void setCurrentSkin(ExtendedSkin currentSkin) {
this.currentSkin = currentSkin;
}
}
The problem here is that the converter is doing its work filling the helloBean.currentSkin object, but the values in the <h:inputText> that are bounded to this helloBean.currentSkin: title, textColor and backgroundColorStart will be send to the server and replace the actual values that were loaded by the converter. In other words:
The converter is executed and builds the helloBean.currentSkin based on the selected value.
The <h:inputText id="name"> empty value is sent to server and will be injected in helloBean.currentSkin.title. Same behavior for the other 2 <h:inputText>s.
The view will be loaded using the selected helloBean.currentSkin and it will load the helloBean.currentSkin.title with the empty value. Same behavior for the other 2 <h:inputText>s.
There are two possible solutions to this problem:
Move the <h:inputText>s outside the form, so the empty values won't be send to the server. When loading the view, it will maintain the values loaded in the converter.
<h:form>
<h:selectOneMenu id="dropdownSkin"
value="#{helloBean.currentSkin}" defaultLabel="Select a skin.."
valueChangeListener="#{helloBean.skinValueChanged}" immediate="true"
onchange="this.form.submit()" converter="SkinConverter" >
<f:selectItems value="#{helloBean.mySkinsSI}" var="c"
itemValue="#{c.value}" />
</h:selectOneMenu>
</h:form>
<br />
<h:inputText id="name" value="#{helloBean.currentSkin.title}"></h:inputText>
<!-- rest of Facelets code... -->
Since you're loading the helloBean.currentSkin while changing the selected value on your dropdownlist, you can add ajax behavior using <f:ajax> tag component inside the <h:selectOneMenu> and update the fields in a cleaner way. I would opt for this solution.
<h:form>
<!-- Note that there's no need of the onchange JavaScript function -->
<h:selectOneMenu id="dropdownSkin"
value="#{helloBean.currentSkin}" defaultLabel="Select a skin.."
valueChangeListener="#{helloBean.skinValueChanged}" immediate="true"
converter="SkinConverter" >
<f:selectItems value="#{helloBean.mySkinsSI}" var="c"
itemValue="#{c.value}" />
<f:ajax process="#this" render="name tcolor bcolor" />
</h:selectOneMenu>
<br />
<h:inputText id="name" value="#{helloBean.currentSkin.title}" />
<h:inputText id="tcolor" value="#{helloBean.currentSkin.titleBar.textColor}" />
<br />
<h:inputText id="bcolor"
value="#{helloBean.currentSkin.titleBar.backgroundColorStart}" />
</h:form>
You can learn more about <f:ajax> in online tutorial like this one.
Since you're going to use an ajax call in your page, you should change your managed bean scope from #SessionScoped to #ViewScoped. More info about this here: Communication in JSF 2

Resources