i'm using JSF 1.2 with IceFaces 1.8.
On my page i got an selectOneListbox, which content (e.g. EQUAL TO, BETWEEN, IN) triggers inputText fields to be rendered. If EQUAL TO is choosen one field is rendered else if BETWEEN is chossen two fields are rendered.
If my validation on the inputText field fails, and i change the content of the listbox the explained rendering does not work.
So has anyone a suggestion how to remove an "invalid" component from the html page?
I set invalid components to invisible.
I use the visible="#{myManagedBean.fieldVisible}" attribute for the component
in my JSF page
and
public boolean isFieldVisible() { return flag; }
in my Managed Bean to achieve this.
Related
I would like to know is there any way to hide/show links to certain pages by using the rendered jsf tag in conjunction with a bean method.
for eg. rendered="#{sidebarController.isGrantedAcess("Admin")} doesn't work
I have a JSF page, with some components rendered if a certain value is selected in SelectOneMenu. For that I change their rendered value and call RequestContext.getCurrentInstance().update("#form").
From the client point of view, whenever I select the value, I get a response from server:
<update id="mainForm:addUser:menu_14:menu">
<...some updated values...>
</update>
Yet, the element with id mainForm:addUser:menu_14:menu did not update.
Can anybody tell me what is wrong?
Update
I can add commandButton with update="#form", and pressing this button actually redraws the form as needed. But I need to do this from the backing bean, so...
From the docs:
public abstract void update(String name)
Update a component with ajax.
name - Client side identifier of the component.
So you can't use selectors like you do from the xhtml file, you have to give client ID of the component.
RequestContext.getCurrentInstance().update("mainForm")
How to programmatically ajax-update specific component in backing bean
Are you using Primefaces? You should pass client id to RequestContext.update method. #form won't work. Try update(mainForm).
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>
I am new to JSF framework and Facelets as view, I am stuck with a problem now. I have got a page where i show some dropdown menu using <h:selectOneMenu> tag. On each selection i used to fire an ajax event using <f:ajax> event it all are working fine. But my problem is, if i select an option 2 on a select box and if I reloads the page again that particular select box will be selected with option 2 by default. I dont need this. I have to reload the select boxes along with page refresh. Please help me to solve this issue.
The selectbox shows the option that is set in the backing bean (and bound by the value attribute of <h:selectOneMenu>). The behavior after a page refresh depends on the scope of your backing bean. If it is session scoped, a page refresh doesn't reset the bean. You could change the scope to #ViewScoped to get the desired behavior. The bean then will be recreated after a full request.
Just set null to backing bean property that used in selectonemenu value after the selected action or set default value in property get method.
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.