Primefaces Picklist problem - jsf

I am having a text field in my xhtml whose property i have set to required="true" and then i have primefaces picklist.
Now when validations fails like mandatory "textbox" is not filled. I throws an error and my page picklist becomes corrupted (all alignment) and if i see in generated html there will be no imports for primefaces like imports for picklist css and js.

I found the answere for the problem myself.
It was actually bcoz of a very silly problem.
One needs to do "render={SomeId of form element}" in the CommandButton.
All the things will work fine then.

Related

Action/ActionListener method checked even if rendered=false

I have a composite component representing a table, that depending on the editable attribute (which I have created) may or may not display links to edit a row.
The edit links are of type <h:commandLink> and have actionListeners pointing to a method in a backing bean. The backing bean for handling editing is provided as a <cc:attribute name="editBean"... /> like the attribute editable, when I want the table to be editable.
If I don't need the table to be editable I set the editable attribute to false and the links rendered attribute gets set to false as well.
My problem is that if I set editable to false and therefore don't set the attribute editBean either, I get errors pointing out that there is no method for handling editing (e.g. java.lang.String does not have the property xxxxx).
I had hoped that as the links are set to not be rendered at all, what has been specified in the action/actionListener would be ignored. To me it feels logical to first check the rendered attribute and then, if it's set to true, check the other attributes.
So, my questions are: why does it work like this and if there's an elegant way of handling this scenario?
Use JSTL <c:if> to conditionally build the component in JSF component tree instead of rendered attribute to conditionally render the HTML output (it's that you're using JSF 2.2, otherwise I'd have explicitly mentioned that this requires a minimum of Mojarra 2.1.18 to avoid broken view state).
<c:if test="#{cc.attrs.editable}">
<h:commandLink ... />
</c:if>

Is there a concept like late binding in in jsf

I have a dialog which includes an XHTML page that has a panel with binding variable set.. I wanted to know if there is a way to call that panel after the dialog is called and not before
<p:panelGrid id="ruleSeqPanelId" binding="#{gssociatedBean.SequencePanel}"
I resolved the issue by adding a condition to the ui:include tag ie
<ui:include src="#{bean.state=='somevalue'?'a.xhtml':'b.xhtl'/>
so my page that has the binding attribute will be set only when the particular condition is satisfied other wise a dummy page is shown. This resolved my issue

primefaces datagrid does not work when rows and columns are defined

I want to represent my data from a MYSQL database table in a primefaces carousel or slider or datagrid with one row. The carousel does not work at all. The datagrid does not work when I add rows="1" attribute and I don't know how to implement my data into a slider.
Any ideas?
I solved the problem. The version of jQuery I had included into my xhtml file was different from that of primefaces jQuery library. So I just used the primefaces jQuery library and deleted the other one and all primefaces components worked as they should.

How to not render whole block in JSF?

Is there a JSF 2.1 component which lets me conditionally render (or not render) all its content? Something like
<h:component rendered="#{user.loggedIn}">
...a bunch of jsf components and HTML code...
...even more HTML code...
</h:component>
I am using PrimeFaces 3M4 as this may influence your answer!
<h:panelGroup>
If you set attribute layout="block", you will have a <div> tag
Otherwise, you have a <span> tag.
In general most of jsf components support the render attribute (never bumped in some that does not),
container components like h:panelGrid or h:panelGroup supports the rendered attribute and if its set to false all its child will be hidden too
Same goes for the primefaces components ,and if not it probably a bug (i think there was an issue with tabview of primefaces)
Here's a link for primefaces user guide, you can find supported attributes of all primefaces components there User’s Guide for 3.0.M4

Ajax with JSF -( No RichFaces / No Ajax4Jsf )

I am using jsf portlets (JSR 168), and i am implementing ajax with JSF ( i have a text field and select one menu, on entering a char on the text field, should get the matching strings on the menu, an auto completion functionality). but i am not using any jsf adv specs like richfaces / facelets etc.. our project is using jdk1.4 still.
so i have a h:inputText with onkeyup event which calls javascript method and gets the values into select one menu. this works perfectly alright.
but later i am trying to submit the form with the textfield value and selectonemenu values using h:commandbutton.
there comes the issue, the action menthod in jsf bean is not getting invoked.
but when i tried removing the onkeyup event from the h:inputtext it works perfectly.
please suggest me. whatz goin on here.
got it resolved... there was a problem with my selectonemenu, it was not identifying the item when it is pulling from ajax. so replaced it with html select for now, but i will figureout a way to build the f:selectitem through javascript.

Resources