Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

S.O.S (selectonemenu does not update)  RSS feed

 
Deniz Kilic
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,i am beginner in JSF ,i have a problem with selectonemenu item.When i choose the an item ,for example ' FirstLabel',outputpanel should be shown.However ,selectone menu does not update my choice.I use primefaces 3.1 library.How can i solve this problem.Thanks for helps.

<p:selectOneMenu value="#{deneme.str}" effect="fold" editable="true" >
<f:selectItem itemLabel="Please choose!." itemValue="" />
<f:selectItem itemLabel="FirstLabel" itemValue="1" />

<f:selectItem itemLabel="SecondLabel" itemValue="2" />

<p:ajax process="@this" update=":Form2:panel1"/>
<p:ajax process="@this" update=":Form2:panel2"/>
</p:selectOneMenu>


</p:outputPanel>


<p:outputPanel id="panel1" rendered="#{deneme.str=='1'}">

<h:outputText value="Output: * " />
<p:inputText id="out" value="#{denemeView.islem}" />



</p:outputPanel>

<p:outputPanel id="panel2" rendered="#{deneme.str=='0'}">

<h:outputText value="True choice! " />
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dnz dnzz",

We don't have many rules here at the JavaRanch, but we do insist that you use your Real Name and not some sort of "handle" or obvious alias. If you're not sure about this, see
http://www.javaranch.com/name.jsp .
 
Deniz Kilic
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that,i did not see its importance.I tried to change from http://www.coderanch.com/forums/user/nameChangeSave but now it cannot update ,i will fix it as soon as possible.

And,do you have any solution about my question?
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Your JSF code looks ok. The 2 <p:ajax> lines can combine into 1. <p:ajax process="@this" update=":Form2:panel1 :Form2:panel2" />

FYI the default event for selectonemenu is valueChange so no specific action listener needed.

What scope is your managed bean? view, request, scope etc.
 
Deniz Kilic
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,Bear Bibeault ,I answered by private message ,name change request page did not update my real name.

And Hello K.Tsang ,i wrote one ajax update now,but still does not work.Here is my DenemeView.java page

@ManagedBean
@ViewScoped
public class Deneme extends BaseView implements Serializable{


private static final Logger log = Logger.getLogger(Deneme.class);
private static final long serialVersionUID = 7435841775773621051L;

@ManagedProperty("#{commonService}")
private CommonService commonService;

private int islem;
private String str;

@PostConstruct
public void init() {
System.out.println("init deneme");

}

public CommonService getCommonService() {
return commonService;
}

public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}

public int getIslem() {
return islem;
}

public void setIslem(int islem) {
this.islem = islem;
}

public String getStr() {
return str;
}

public void setStr(String str) {
this.str = str;
}
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!