Thursday, October 29, 2015

Setting width Inplace Component Primefaces


In an hour ago I have a  problem with inplace component then Aceh Gayo coffee was gave me the idea.

taken from www.foodspotting.com

There is no properties for setting width in inplace component, but if you look at html code that produced by primefaces you will find the span element for wrapping the text in inplace component.

Then you just need little html knowledge to setting span width in other words is inplace width.
Here the code :

 <p:inplace id="inOutput4" editor="true" style="display:inline-block;width:250px;overflow:hidden">  
   <p:inputText id="output4" value="#{bean.output}" required="true" />  
 </p:inplace>  

Yes, I use style="display:inline-block;width:250px;overflow:hidden"  for set the width.




Saturday, October 10, 2015

Jsf, Getting url parameter value

Source image: wallpaperseries.com
Good morning, people!
Have you drink your coffee today? I'm drinking a cup of americano from nearby store. :)


Let say you have to get param value in http://localhost:8080/apps/faces/test.xhtml?param=hello.
All you need is just add view param in your xhtml file and mapped it with a variable in managed bean.

xhtml Code :
 <f:metadata>  
     <f:viewParam name="param" value="#{testBean.message}" />  
 </f:metadata>  

Managed Bean Code :
 @ManagedBean(name = "testBean")  
 @ViewScoped  
 public class TestBean implements Serializable {  
   private String message;  
   public String getMessage(){  
     return message;  
   }  
   public String setMessage(String message){  
     this.message = message;  
   }  
 }