The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

Showing posts sorted by relevance for query primefaces. Sort by date Show all posts
Showing posts sorted by relevance for query primefaces. Sort by date Show all posts

20131203

[SOLVED] eclipse jsf attribute autocomplete not working for primefaces tag p:toolbarGroup: "no default proposals"

I debugging some weird eclipse behavior today: the "jsf attribute autocomplete" functionality (ctrl+space inside a primefaces tag) didn't seem to work today in a particular file i was coding.

i had the following simple code:
<p:toolBarGroup ...

but when i'd invoke autocomplete for available attributes for that tag, eclipse was just returning "no default proposals".

i finally figured out 2 things that were wrong in the file:

* the <html ...> tag was missing the primefaces library namespace declaration (and was the old code from our app's previous jsf framework, richfaces), so i had to add it:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">



* also, we're converting our app from richfaces to primefaces, so the old code was:
<rich:toolBarGroup ...

but the primefaces tag documentation/api for p:toolbarGroup uses a lowercase "b", instead of uppercase "B" in "toolbar", i.e.:
<p:toolbarGroup ...

so, the case of the tag name was the problem bc tag names are case-sensitive.

20140319

primefaces - show p:modalPanel from java backing bean / controller class and update specific id or collection of id strings

here's how you show a p:modalPanel from a java backing bean call:
org.primefaces.context.RequestContext.getCurrentInstance().execute("myModalPanelWV.show()");

"modalPanelWV" is the widgetVar value, e.g.:
<p:modalPanel id="myModalPanel" widgetVar="myModalPanelWV" ...

update an id from backing bean:
org.primefaces.context.RequestContext.getCurrentInstance().update("growl");

OR update a Collection<String> of IDs:
org.primefaces.context.RequestContext.getCurrentInstance().update(myCollectionOfStringIds);



20140321

sahi, primefaces: "ReferenceError: PrimeFaces is not defined". solution: just rerun the sahi script

sometimes when i run a sahi script to test our primefaces ui, the script times out with the following error:

ReferenceError: PrimeFaces is not defined (http://localhost/pages/listTransportAgreements.jsf:278)

when i rerun the script, it usually goes away, so i'm not quite sure why it works sometimes and other times it doesn't.

20140109

how to convert richfaces a4j:actionparam tags (that don't use "assignTo" attribute) to primefaces

during our migration from richfaces to primefaces, i stumbled across the richfaces tag a4j:actionparam (demo), e.g.:

<p:menuitem value="#{msg['label.showTrackAndTrace']}"
    ...
    actionListener="#{listTRQDataModel.fetchCurrentRow}">
    <a4j:actionparam name="row" value="{currentRowNo}" />
    <a4j:actionparam name="actionName" value="viewTNTListTrips" />
</p:menuitem>


luckily, since it doesn't use the assignTo attribute, the conversion of this tag to primefaces is pretty simple:

<p:menuitem value="#{msg['label.showTrackAndTrace']}"
    ...
    actionListener="#{listTRQDataModel.fetchCurrentRow}">
    <f:param name="row" value="{currentRowNo}" />
    <f:param name="actionName" value="viewTNTListTrips" />
</p:menuitem>


NOTE: f:param would have worked just as fine in richfaces, but for some reason, whoever coded the old version used a4j:actionparam instead (overkill and unnecessary).

see also the great f:param tutorial by mkyong.

20131113

[WORKAROUND] eclipse kepler - primefaces 4 xhtml/jsf autocomplete no description for attributes

i have my primefaces jar included in my project build path, and when i do ctrl+space in an xhtml/jsf file, inside a primefaces tag, i get the list of available attributes, but there's no description for them:


i found a workaround by accident: when the autocomplete window is open, as shown in the screenshot above, do ctrl+space again, several times, until you rotate back to the attributes list, and THEN the description will show:


20140321

[SOLVED] sahi, primefaces: p:dataTable no rendered table tag id

i'm updating our sahi test scripts for our new primefaces frontend and ran into a difficulty when trying to select a specific table row cell.

this page gives a hint as to how to select specific table cells:
http://sahi.co.in/docs/faq/get-cell-data.html

using this format:
_cell(_table("<table_identifier>"), x-1, y-1)


but the problem is that when a primefaces p:dataTable gets rendered to HTML, the table is enclosed in a div tag, and that div tag gets the id value set in the p:dataTable code, and the actual table tag doesn't have an id.

i solved my problem like this:
_cell(_table(1, _in(_div("selectMember:selectMemberTable"))), 1, 1)

here i specify the *second* table (there's a table in the header too), which is the actual dataTable table (0-based indexing, so value "1").

however, from what i can see, the sahi documentation is confusing concerning "x" and "y", if you interpret "x" to mean column (left<->right position), like i do.

"...1, 1)", in reality, means "row 2 (x), column 2 (y)" (0-based indexing, so "1, 1")

------------

as a side note, i found this sahi script code useful/interesting too:
_table(0, _in(_div("selectMember:selectMemberTable"))).rows[0].style='background-color:red'

which changes the background color of the first row of the first table to red.

20140402

[SOLVED] sahi _setSelected not working with primefaces 4, but works with richfaces 3. workaround

back when we were using richfaces 3, this code worked fine:
_setSelected(_select("myForm:ChrgTrsTbl:0:price_chargeCode_input"), "CustClearance");

but it doesn't seem to work with primefaces 4. this, however, seems to work fine:

_click(_listItem("CustClearance"));


20140320

primefaces p:commandLink oncomplete attribute referencing non-existent ID was messing up table filter and sort functions


i had this primefaces delete-icon code in a table row:
<p:commandLink id="deletelink" title="#{msg['label.delete']}"
    action="#{ta_mappingObject.setCurrentItemAndPanelToShow(agreement, 'deleteTA')}"
    rendered="#{!ta_mappingObject.createFromRequestDetails and userMenuBean.canEditAgreement()}"
    oncomplete="PF('confDeleteAgreement').show();">
    <h:graphicImage value="/images/icons/delete.gif" style="border:0" />
</p:commandLink>


and stuff on the page like filtering and sorting wasn't working, so i figured out that because that link was referencing a dialog ID that didn't exist, it was messing up the whole page, so i changed it to this:
<p:commandLink id="deletelink" title="#{msg['label.delete']}"
    action="#{ta_mappingObject.setCurrentItemAndPanelToShow(agreement, 'deleteTA')}"
    rendered="#{!ta_mappingObject.createFromRequestDetails and userMenuBean.canEditAgreement()}"
    oncomplete="PF('andIdThatExists').show();">
    <h:graphicImage value="/images/icons/delete.gif" style="border:0" />
</p:commandLink>



and everything started working again.

20131210

[SOLVED] primefaces: javax.faces.FacesException: Cannot find component with expression "X" referenced from "Y". how to show/open p:dialog outside of naming container/in external form

i had the following code below, which has a link inside a form, and when a user clicks on the link, a p:dialog (outside of the form that contains the link and inside a different form) should open:
<ui:composition template="/templates/tctemplate.xhtml">
    <ui:define name="body">
        <h:form id="deviationForm">
            <p:toolbar>
                <p:toolbarGroup>
                    <p:commandLink update=":search:searchPanelHolder" id="searchFilter" onclick="PF('CDD_filterPanelWV').show();"
                        value="search/filter" />
                </p:toolbarGroup>
            </p:toolbar>
            <ui:include
                src="/webcomponents/costDevTable.xhtml" />
        </h:form>
    </ui:define>


    <p:dialog id="CDD_filterPanel" widgetVar="CDD_filterPanelWV">
        <h:form id="search">
            <h:panelGrid columns="2" id="searchPanelHolder">
                ...
                <h:outputLabel for="fromDate" value="from date" />
                ...
            </h:panelGrid>
        </h:form>
    </p:dialog>

</ui:composition>

but when i clicked the p:commandLink link and tried to open/show the p:dialog, i would get the following error:

javax.faces.FacesException: Cannot find component with expression ":search:searchPanelHolder" referenced from "deviationForm:searchFilter"

eventually, i realized that the error was simple: the p:dialog was outside the ui:define tag.

so here's how the code should look:

<ui:composition template="/templates/tctemplate.xhtml">
    <ui:define name="body">
        <h:form id="deviationForm">
            <p:toolbar>
                <p:toolbarGroup>
                    <p:commandLink update=":search:searchPanelHolder" id="searchFilter" onclick="PF('CDD_filterPanelWV').show();"
                        value="search/filter" />
                </p:toolbarGroup>
            </p:toolbar>
            <ui:include
                src="/webcomponents/costDevTable.xhtml" />
        </h:form>
 

        <p:dialog id="CDD_filterPanel" widgetVar="CDD_filterPanelWV">
            <h:form id="search">
                <h:panelGrid columns="2" id="searchPanelHolder">
                    ...
                    <h:outputLabel for="fromDate" value="from date" />
                    ...
                </h:panelGrid>
            </h:form>
        </p:dialog>
    </ui:define>
</ui:composition>



thanks to this thread for leading me in the right direction:
Naming Container in JSF2/PrimeFaces

20120412

can't browse repositories from svn root in eclipse - repository has been moved svn: repository moved permanently to X; please relocate


before you set up SVN, i suggest you read these 2 links below.

there's 2 ways to set up svn:
* 1 repository
* multiple repositories
http://subversion.apache.org/faq.html#multi-proj

here's a discussion about the pros and cons of each method:

when i tried to list the repos in eclipse's svn browser with the following url:
http://example.com/svn

i would get the following error:
error validating location: "org.tigris.subversion.javahl.ClientException: repository has been moved
svn: repository moved permanently to X; please relocate

this is because i chose method 2, multiple repositories, so svn isn't a repository, thus the error message is technically correct.


UPDATE 20131030

i ran into this same error today while trying to create a tag from trunk, like this:
svn copy https://example.com/repos/myrepo/trunk/ https://example.com/repos/myrepo/tags/20131029-nick-rich-extdt/ -m "almost got context menu for trq list working, but dan says to start with primefaces instead"

which gave this output:
svn: Repository moved permanently to 'https://example.com/repos/tc_inc2/'; please relocate


all i had to do to make it work was just change "repos" to "svn" (both are valid for browsing the repo, but it required that i used "svn":
svn copy https://example.com/svn/myrepo/trunk/ https://example.com/svn/myrepo/tags/20131029-nick-rich-extdt/ -m "almost got context menu for trq list working, but dan says to start with primefaces instead"


20120921

regexp examples for eclipse that match specific html/jsf tag and attribute names and also parsing java code

been working for hours on a regex to match all instances of a specific jsf tag name with a specific attribute name, practically getting an ulcer, and i finally figured out a simple solution:
TAG_NAME[^>]+ATTRIBUTE_NAME\s*=

if TAG_NAME == convertDateTime
if ATTRIBUTE_NAME == locale

then it will match e.g.:
<f:convertDateTime type="both" dateStyle="short"
locale=
"en" timeZone="Europe/Oslo" />

and

<f:convertDateTime locale="#{myBean.localeString}" type="date" dateStyle="medium" timeZone="Europe/Oslo" />



[^>]
this means no tag-close character, because we don't want matches like this:
<f:convertDateTime type="both" dateStyle="short" timeZone="Europe/Oslo" />
<rich:calendar locale="en" datePattern="dd.MM.yyyy"...

we want to stop the searching/matching at the end of the f:convertDateTime tag:
<f:convertDateTime type="both" dateStyle="short" timeZone="Europe/Oslo" />
<rich:calendar locale="en" datePattern="dd.MM.yyyy"...


\s*=
this means that 0 or more whitespace can be between the ATTRIBUTE_NAME and the equals sign. e.g. this would also get matched:
<f:convertDateTime locale   ="#{myBean.localeString}" type="date" dateStyle="medium" timeZone="Europe/Oslo" />


i couldn't find this solution anywhere and was surprised to find so few asking for it, but lots of people writing things like "you can't use regular expressions to parse html" (a post on Stack Overflow that got 4432 positive votes!).

here's a regexp that works in eclipse for finding a tag WITHOUT a specific attribute (i've tested it):
TAGNAME(?:\s+(?!ATTRIBUTENAME\b)[\w\-.:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[\w\-.:]+))?)*\s*/?>

#######

here's an example of regexp search and replace in eclipse that uses grouping and back references for rich:calendar tags with locale attribute that either have a normal hardcoded text string value (e.g. "en") OR a backing/managed bean expression value (e.g. "#{someBean.someValue}") OR empty value (""):
(rich:calendar[^>]*locale\s*=\s*")[^"]*
replace with:
\1#\{myBean\.usersLocale\}

this inserts the Locale value returned from MyBean.getUsersLocale()


[^"]*
this means to match everything (0 matches to infinity) that isn't a ", i.e. stop matching once you reach the locale attribute's closing quote, ", e.g.:
<rich:calendar value="#{myBean.toDate}"  requiredMessage="required"
locale="no/NO"
datePattern="dd.MM.yyyy"
required="true"
/>
so the whole regex would match (everything in bold) e.g.:
<rich:calendar value="#{myBean.toDate}"  requiredMessage="required"
locale="
no/NO
"
datePattern="dd.MM.yyyy"
required="true"
/>
and the text with green background denotes the first back reference (\1) group, i.e.:
(rich:calendar[^>]*locale\s*=\s*")[^"]*
the enclosing parentheses ( and ) denote a grouping, so everything inside those parentheses that matches gets saved and pasted back into the result, using a backreference, e.g.: \1
for the first back reference, \2 for the second back reference/grouping, etc, e.g.:
(text-grouping-to-save-1)text-to-replace(text-grouping-to-save-2)
replace with:
\1new-text-to-replace-old-text\2

which would result in:
text-grouping-to-save-1new-text-to-replace-old-texttext-grouping-to-save-2

##############

here's one that finds all elements with a locale attribute that doesn't have the value "#{myBean.usersLocale}":
locale\s*=\s*"(?!#\{myBean\.usersLocale\})[^"]*

(?!XXX)
means match text that ISN'T equal to XXX, and don't create a back reference for it--denoted by the question mark, ?

(?:XXX)
would mean: match text that IS equal to XXX, and don't create a back reference for it


###############

someone had coded f:converter tags with a locale attribute, e.g.:
<f:converter locale="#{myBean.localeString}"
converterId="CustomIntConverter" />

so i needed a regex to delete all these locale attributes from all f:converter tags because locale isn't supported in this tag--not in jsf 1.2, 2.0 or 2.1! (however it is supported for related tags like f:convertDateTime and f:convertNumber)

here's the regex search:
(f:converter\s+[^>]*)locale\s*=\s*"[^"]*"

and replace with:
\1


i.e. keep everything that matched up until the locale attribute, and delete the locale attribute and its quoted value.



################

my next problem was finding all jsf tags that use some pageProps OR pageProperties class objects to get a property value and replace all references to such java classes with a standard resource bundle variable, msg, while at the same time keeping and reusing the properties label string value--yes, all in one search and replace!

so, i have code lines like this:
value="#{myBean.isBuyer ? myBean.pageProps.getPropertyValue('label.deviation.buyerdetails',  myBean.locale) : myBean.pageProps.getPropertyValue('label.deviation.transporterdetails',  myBean.locale)}"
...
value="#{myOtherBean.pageProperties.propertyValue('label.deviation.buyerdetails',  myBean.locale)}"

but i also have lines like this, that i don't want to match:
...
timeZone="#{myOtherBean.pageProperties.timeZone}" />

i want the resulting lines to look like this:
value="#{myBean.isBuyer ? msg['label.deviation.buyerdetails'] : msg['label.deviation.transporterdetails']}"
...
value="#{msg['label.deviation.transporterdetails']}"

to do this, i use a regexp search like this, in eclipse:
\w+Bean\.pageProp\w+\.\w+rop[^']+'([^']+)'[^\)]*\)
replace with:
msg\['\1'\]


##########SORT OF UNSOLVED MYSTERY ###############

here i have a java method:
    private String getPropertyValue(String property) {
        if(props == null)
            props = new RBUtils(Locale.ENGLISH, null);
        return RBUtils.getString(property, null, null);
    }


i want to find all java methods with that specific name and remove all lines before the return statement, like this:
    private String getPropertyValue(String property) {
        return RBUtils.getString(property, null, null);
    }


 
here's the regexp that took me about an hour to come up with:
search for:
(String\s+getPropertyValue\([^\{]+\{)[\s\S]+?(return\s+RBUtils)
replace with:
\1\n\2


explanation:
\s\S
matches any character

\n is just to place a newline in front of the return statement.

? is to stop greediness and force laziness.

UPDATE
this one will "fail" if you have the following code:
    private String getPropertyValue(String property){
        String s= RBUtils.getString(property, null, null);
        return s;
    }

    public String getPropertyLabelValue(String property){
        return RBUtils
.getString("label."+property, null, null);
    }


so i need to figure out how to stop the matching at the end of the method. one idea i have is to stop it at a public OR private, i.e. if it hasn't matched before it reaches a "public" or "private" string, then it's not a match.

let's try to put to words exactly what i want:
* i want to match within a method with the following signature:
String getPropertyValue(String name)

where name can be any string: \w+
and the preceding text is a string literal: (String\s+getPropertyValue\s*\(\s*String\s+)

so the whole first line is:
(String\s+getPropertyValue\s*\(\s*String\s+\w+)

the surrounding parentheses are a grouping, so we can save that text and reinsert it in the replace action by using what is called a backreference, like this:
\1

to end the matching at the end of the method is quite difficult though, if not impossible, illustrated by the following examples.

one way is to stop the matching at the first instance of a private or public:
    private String getPropertyValue(String property){
        String s= RBUtils.getString(property, null, null);
        return s;
    }

    public ...


(note: this doesn't match because we didn't find "return RBUtils")

but if you have the following code:
...
    private String getPropertyValue(String property){
        String s= RBUtils.getString(property, null, null);
        return s;
    }
} // end of the java class


there is no method after the method we're interested in--the class ends. one solution would be to somehow count the number of curly braces and stop at the last "}". i don't know how to do that or if that's possible, so someone please let me know =)

what i originally, specifically wanted was to match the following:
    private String getPropertyValue(String property) {
        if(props == null)
            props = new RBUtils(Locale.ENGLISH, null);
        return RBUtils.getString(property, null, null);
    }


so to solve this specific problem (instead of finding all methods with that signature and erasing any variation of code before the return statement--which currently seems impossible) i need to use the following regex:
(String\ +getPropertyValue\ *\(\ *String.+\s)(?:.+props.+\s){2}(.+\s.+\})
replace with:
\1\2

(?:          //group, but don't make a backreference
.+props.+\s          //match a whole line, including the newline (\s) that contains  "props"
)          //end grouping
{2}          //match that "props" line max 2 times

(.+\s.+\})          //match the whole "return" line, plus the line with the method-closing curly brace and put all this into a group, so we can backreference this second group with \2


#####################

today's fun example, 20120928, was about me figuring out that you can't use a "+" sign to dynamically concatenate label text and then get that label property value from a properties file. luckily i found this post that told me i could use EL 2.2's concat functionality.

so i need to convert all instances of this kind of JSF code:
#{msg['random-text-1'+random-text-2]}
to this:
#{msg['random-text-1-reinserted-here'.concat(random-text-2-reinserted-here)]}
search for:
(#\{\s*msg\[\s*'[^']+')\s*\+\s*(\w[^\]]+)
replace with:
\1\.concat\(\2\)


UPDATE 20131119

this regex searches for primefaces tags that have an update attribute, but are missing an update id for growl:
\bupdate\s*=[\s:a-zA-Z]*"(?!:growl)[^"]*


UPDATE 20131211

after migrating from richfaces to primefaces, i needed to remove all calendar attributes called "verticalOffset" (valid in rich:calendar, but not in p:calendar):

search/match:
verticalOffset\s*=\s*"-*[0-9]+"

replace with:
(nothing)


20131106

[SOLVED] java ee xhtml, how to hide jsf tags in source code

today's task at work was to find out how to hide xhtml tag code in jsf pages, i.e. when a user attempts "view > source code", we don't want them to see the non-rendered jsf tags. i searched a lot, using the following search phrases:
jsf hide source code
primefaces hide source code
jsf don't show source code
jee hide jsf source code
jee web.xml hide jsf source
hide xhtml source
jsf disable viewing xhtml source

but surprisingly found no concrete answer as to how to solve this, but after much trial and error, i've finally figured it out.

put this code in your web.xml:

<servlet>
    <servlet-name>facesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    <url-pattern>*.xhtml</url-pattern>

    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>



20140210

cascading primefaces "p:contextMenu"s?

i have a p:contextMenu for a p:dataTable, but inside the table is a p:rowExpansion which contains a p:dataTable, with a p:contextMenu for that inner datatable, but the "outer" p:contextMenu seems to be overriding the "inner" p:contextMenu.

<p:contextMenu for="tripTable">
    <p:menuitem value="context menu item for main dataTable" />
</p:contextMenu>

<p:dataTable id="tripTable" rowKey="#{listObj.id}"
    selection="#{
listTrqsDataModel.tripBean.currentItem}"
    selectionMode="single"
    value="#{
listTrqsDataModel.tripBean.dataList}" var="listObj"
    rows="#{listTrqsDataModel.tripBean.noOfItemsListedPrPage}">
    <p:column>
        <p:rowToggler />
    </p:column>
    <p:column>
        ...           
    </p:column>
    <p:rowExpansion>
        <p:contextMenu for="tripTRQTable">
            <p:menuitem value="context menu item for rowExpansion dataTable" />
        </p:contextMenu>
        <p:dataTable id="tripTRQTable" ... >
            <p:column>
                ...
            </p:column>
        </p:dataTable>
    </p:rowExpansion>
</p:dataTable>



not sure how to make this work... anyone?


UPDATE 20140210

it seems like a workaround for this is to remove the "for" attribute in the inner contextMenu--making its scope for the whole page, while the outer contextMenu is still working for the outer dataTable, i.e.:

    <p:rowExpansion>
        <p:contextMenu for="tripTRQTable">
            <p:menuitem value="context menu item for rowExpansion dataTable" />
        </p:contextMenu>
        <p:dataTable id="tripTRQTable" ... >
            <p:column>
                ...
            </p:column>
        </p:dataTable>



UPDATE 20140217

doesn't look like the workaround is very reliable. once the "inner" context menu is enabled, the "outer" doesn't show. looks like i'll have to use a button/icon instead of context menus, for now...


20131119

[SOLVED] primefaces p:dialog not rendering ui:include page component content

i have a p:dialog that looks like this:

<p:dialog ...>  
    <p:panel>
        <ui:include src="/webcomponents/presentation/user/testUserMenu.xhtml" />
    </p:panel>
</p:dialog>

(NOTE: "..." just means "etc/some code")

testUserMenu.xhtml looks like this:

...
<p:panelGrid id="testUserMenu">
...
    <p:commandButton value="#{msg['label.close']}" ... />

...
</p:panelGrid>
...


but the "close" button, nor anything else in the p:dialog, was getting rendered in the browser.
finally, i figured out (thanks to my colleague dan) that p:panelGrid simply needed a defined "columns" attribute, like this:

<p:panelGrid id="testUserMenu" columns="1">

20140114

[SOLVED] primefaces p:rowToggler and p:rowExpansion not working, not toggling

 i was near pulling my hair out when i couldn't get a simple table row toggle (DataTable row expansion) working. nothing was happening when i clicked on the toggle icon image. my colleague took a look at it and finally discovered the problem:
the p:rowToggler was inside an embedded p:column:

<p:dataTable...>
    <p:column...>
        <h:panelGrid...>
            <p:column...>
                <p:rowToggler />
                ...
            </p:column>

        </h:panelGrid>
    </p:column>
    ...
    <p:rowExpansion>
        <p:dataTable...>
            <p:column...>
            ...
            <p:column>
            ...
    <p:rowExpansion>
</p:dataTable>


the solution was easy--just remove the embedded p:column:

<p:dataTable...>
    <p:column...>
        <h:panelGrid...>
            <p:rowToggler />
            ...
        </h:panelGrid>
    </p:column>
    ...
    <p:rowExpansion>
        <p:dataTable...>
            <p:column...>
            ...
            <p:column>
            ...
    <p:rowExpansion>
</p:dataTable>

20140117

[SOLVED] primefaces click on p:commandLink doesn't work, nothing happens. firebug helped me easily find the error.


In firefox, i clicked on the magnifying glass (top left in above image) icon link that seemed to not be working. When i clicked on the image, nothing happened.


I originally tried a (bad and risky) workaround for this by setting the p:commandLink's "immediate" attribute to "true":

<p:commandLink
    actionListener="#{lrdm.openTRQDetails(trq.id)}"
    update=":growl :panelContent" immediate="true">
    <h:graphicImage value="/images/search.gif" style="border:0" />
</p:commandLink>


this "worked", but simply hid the error, so this isn't a solution.

Eventually, I found out that it was a hidden error: java.lang.NullPointerException

Here's how i found that:

In firebug > Console > All
i expanded the POST line and could see a clue about the error in the Response tab:

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><error><error-name>class javax.faces.component.UpdateModelException</error-name><error-message><![CDATA[/path/to/inplaceInputText.xhtml @16,60 value="#{inputValue}": /path/to/tripRow.xhtml @53,69 value="#{backingBean.description}": java.lang.NullPointerException]]></error-message></error></partial-response>


here's the problem code in "backingBean"

...

public void setDescription(String description) {
    this.description = description.toUpperCase();
}

...


the error was occurring when "description" was null--toUpperCase() will obviously throw an error.

to fix this, i changed the code to this:

public void setDescription(String description) {
    if(description != null)
    this.description = description.toUpperCase();
    else this.description = description;
}


Once that was fixed, the form submitted properly :)

20140103

[SOLVED] JBoss EAP6, JSF, Primefaces: "Unable to find matching navigation case with from-view-id..."

our company app is configured so that when a user clicks the login button from the front page, and index.html file redirects the user to the main page of the authenticated/authorized area of our app, index.xhmtl (rendered as index.jsf), but since the user hasn't logged in yet, they are shown the login page: login.xhml (rendered as login.jsf), BUT in the browser URI field it shows:
examples.com/index.jsf






my problem was trying to get a navigation rule working, so that if during the authentication/login process, if the app found out that the user needed to change his password, he would be redirected to /newPassword.xhtml

but it wasn't working and i was getting this error:
"Unable to find matching navigation case with from-view-id login.xhtml..."

i found out eventually that the from-view-id needed to be the page that was shown in the browser URI field, namely index.xhtml, and not login.xhtml.


here are the relevant code and configurations.

#############
/login.xhtml
#############

<p:commandButton value="Login" update="checkPassword" action="#{loginBean.login}" ... />


#############
LoginBean.java
#############




...
private String changePass = "newPassword";
...
public String login() {
    ...

    if(mustChangePassword) {
        ...
        return changePass;
    }
}

...


#############
WEB-INF/faces-config.xml
#############

<faces-config ... >

    <navigation-rule>
        <from-view-id>/index.xhtml</from-view-id>

        <navigation-case>
            <from-action>#{loginBean.login()}</from-action>
            <from-outcome>newPassword</from-outcome>
            <to-view-id>/newPassword.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        ...
    </navigation-rule>

</faces-config>