The best place to ask programming/development questions, imo. UPDATE: stackoverflow is 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 a great reference for finding answers.

My Music (Nickleus)

20130126

ubuntu precise 12.04 - how to install lmms with vst support

UPDATE 20130205: How to install LMMS 0.4.14-rc1 with VST support on Ubuntu 12.04 (Precise Pangolin)


by installing lmms the normal way in the normal ubuntu package system:
sudo apt-get install lmms

there's no vst/vestige in lmms, so i ran this command:
sudo apt-get install lmms-vst

but got the following message:
Unable to locate package lmms-vst

NOTE: the ubuntu 12.04 lmms version is 0.4.10

TO GET LMMS WITH VST SUPPORT DO THIS:


sudo add-apt-repository ppa:irie/lmms


after running this you'll get the following message:
To use the VST support with Wine, you have to assign /usr/lib/lmms to some drive letter using Wine configuration (winecfg)

winecfg

drives > add (a drive--it suggested D: for me)
click D:
path: /usr/lib/lmms
ok/save

sudo apt-get update
sudo apt-get install lmms


NOTE: the irie/lmms PPA will install lmms version 0.4.13!

20130125

[SOLVED] richfaces rich:calendar button icon image breaking to new line. how to make it not wrap

this tutorial didn't work for me:
rich:calendar icon not displaying on same line as display box

i solved this by adding a styleClass to the surrounding panel grid:
<h:panelGrid columns="2" styleClass="tadCal">
    <h:outputText value="from date:" />
    <rich:calendar buttonIcon="/images/icons/cal_.gif" ... />
</h:panelGrid>




then in my css file i span elements not wrap to a new line.
style.css:

.tadCal span {
    white-space: nowrap;
}


because this is what a rich:calendar looks like when rendered:
<span>
<input type="text" .../>
<img .../>
<input type="hidden" .../>
</span>

20130122

[SOLVED] javax.el.PropertyNotFoundException: listTADs.xhtml value="#{del.name}": Property 'name' not found on type org.hibernate.collection.PersistentSet

i'm currently working on cutting out wrapper classes in one area of our application, and using the entity directly instead of a wrapper class, and i came across a weird error when i tried iterating a Set in the entity:

javax.el.PropertyNotFoundException: listTADs.xhtml value="#{del.name}": Property 'name' not found on type org.hibernate.collection.PersistentSet

here's some of the code.

##########

TAD.java:

@Entity
@Table(name = "TAD")
...
public class TAD extends Persistent implements Serializable {
...
    /** The despatch party*/
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name="ADP",
            joinColumns={@JoinColumn(name="AGREEMENT_ID")},
            inverseJoinColumns={@JoinColumn(name="PARTY_ID")})
    private Set<TAP> despatchParties  = new HashSet<TAP>();
...
    public Set<TAP> getDespatchParties() {
        return despatchParties;
    }
...



TAP.java:

@Entity
@Table(name = "TAP")
...
public class TAP extends Persistent implements Serializable {
...
    /** The name */
    @Column(name = "NAME")
    @Basic(fetch = FetchType.EAGER)
    private String name;
...
    public String getName() {
        return name;
    }



listTADs.xhtml:

<rich:dataTable id="pickupParties" value="#{tad.despatchParties}" var="del">
    <rich:column>
        <f:facet name="header">
            <h:outputText
                value="#{msg['label.db.PARTY_NAME']}" />
        </f:facet>
        <h:outputText value="#{del.name}"></h:outputText>
    </rich:column>
...


##########

what was happening was that despatchParties.size() was always 1 no matter how many entries it had, e.g. 3 TAPs, and the del var was the container for the actual set, so the application was trying to call getName() on the whole Set--which obviously wouldn't work because java.util.Set doesn't have a getName() method. it looked like this:

Method not found: [TAP [id=2745, agreementOwnerId=TestBuyer, name=XHentested_1469, idInAgreement=XHID_1469, eanLocationNumber=null, ldapId=null, city=Oslo, postCode=0152, street=Prinsens gt. 1, role=Despatch Party, parentOrganizationId=null, goodstype=null, countryCode=NO, contact=example@example.no, language=no_NO, langRole=null, selected=false, referredPartyId=null]].getName()


so to iterate the Set in the rich:dataTable i had to add a toArray() call so that del var would be an entry in the actual set:

<rich:dataTable id="pickupParties" value="#{tad.despatchParties.toArray()}" var="del">
    <rich:column>
        <f:facet name="header">
            <h:outputText
                value="#{msg['label.db.PARTY_NAME']}" />
        </f:facet>
        <h:outputText value="#{del.name}"></h:outputText>
    </rich:column>
...

20130121

[SOLVED] richfaces a4j:commandButton action method not getting called

i was having problems yesterday after recoding some jsf pages--the method saveParty wasn't getting called.


listTADs.xhtml (includes the file below, listTADParties.xhtml):

...
<rich:modalPanel id="modalPanelTA" autosized="true">
...
    <a4j:outputPanel id="modalPanelTA_content">
        <h:form>
            <h:panelGroup rendered="#{tadController.panelToShow == 'viewParties'}">
                <ui:include src="/listTADParties.xhtml" />
            </h:panelGroup>
        </h:form>
    </a4j:outputPanel>
</rich:modalPanel>
...



listTADParties.xhtml:

...
<rich:modalPanel>
    <h:form>
        ...
        <a4j:commandButton action="#{tadController.saveParty}" value="save" reRender="transportAgreementPartiesTbl"
            oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPartiesPanel')}.hide();"/>
        ...
    </h:form>
</rich:modalPanel>
...






the solution was removing the parent h:form in listTADs.xhtml (the problem was the form inside the other/parent form):

...
<a4j:outputPanel id="modalPanelTA_content">
    <h:panelGroup rendered="#{tadController.panelToShow == 'viewParties'}">
        <ui:include src="/listTADParties.xhtml" />
    </h:panelGroup>
</a4j:outputPanel>
...

20130116

[SOLVED] "unexpected AST node: :" - jpql named parameter can't contain period/full stop character, e.g. "transporter.name"

i had the following jpql in my java jee services bean:
select tad from TADS tad  WHERE tad.agreementOwnerId = :agreementOwnerId  AND upper(tad.transportCompany.name) LIKE :transporter.name ORDER BY tad.agreementNumber DESC, tad.id DESC

when i tried running the query i got the following error:

"unexpected AST node: :"

after some testing i found out that jpql query named parameters can't contain characters that are not a valid identifier as defined by Character.isJavaIdentifierPart e.g. period/full stop character (".").
e.g. a named parameter like "transporter.name" is invalid

the error message "unexpected AST node: :" was complaining about the ":" next to the named parameter "transporter.name", but the real problem was the "." in the named parameter. the named parameter should be rewritten to be something like "transporterName"

DOH!

so, this jqpl query string works:
select tad from TADS tad  WHERE tad.agreementOwnerId = :agreementOwnerId  AND upper(tad.transportCompany.name) LIKE :transporterName ORDER BY tad.agreementNumber DESC, tad.id DESC

afterwards, i found that this is also explained at stackoverflow:
JPA NamedQuery parameters

20130115

sql getting multiple/duplicate rows for query using IN

in our java jee EJB3 application we have a list page that lists transport agreements domestic records (TADs).
at the top of the table in the header we have an input field where we can filter the results for e.g. postal/zip code (postnummer) for despatch parties (hentested).

the normal, unfiltered list:


there are only 11 TAD records, but when i filtered the search for postal code it looked like this, with duplicated records/rows and the count was 16 (should only be 10 since one of the records doesn't match the filter "00"):



the ql codes looked like this:

for the count value at the bottom (R:16), ("R" means "Records"):

select count(tad.id) from TADS tad , IN (tad.despatchParties) desps WHERE tad.agreementOwnerId = :agreementOwneId  AND desps.postCode LIKE :despatchPostCode

and this, for the actual records in the list:

select tad from TADS tad , IN (tad.despatchParties) desps WHERE tad.agreementOwnerId = :agreementOwneId  AND desps.postCode LIKE :despatchPostCode


the fix for this was actually pretty simple:

for the count value at the bottom:

select count(distinct tad.id) from TADS tad , IN (tad.despatchParties) desps WHERE tad.agreementOwnerId = :agreementOwneId  AND desps.postCode LIKE :despatchPostCode

and this, for the actual records in the list:

select distinct tad from TADS tad , IN (tad.despatchParties) desps WHERE tad.agreementOwnerId = :agreementOwneId  AND desps.postCode LIKE :despatchPostCode

so now the filtered list looks correct:


i see now that this subject is also discussed on stackoverflow:
SQL Server query - Selecting COUNT(*) with DISTINCT

20130107

regex - how to match string, but not xxstring

(explanation of blog post title: where xx is any number of letters)

i want to find/search for all instances of "change" in a file in eclipse, but NOT match instances of "onchange":

\bchange

will match strings like:

change in:
<h:outputText value="Please change your password" />

changePwdPanel in:
oncomplete="#{rich:component('changePwdPanel')}.show()" />

BUT NOT

onchange in:
<a4j:support event="onchange" reRender="additionalConfigReqion">


\b is a word boundary

thanks to Jan Goyvaerts's post How to match whole words with a regular expression for pointing me in the right direction :)

---
search strings i googled to find the answer i was looking for:
regex match whole word
regex match string dont match certain part of the string

[SOLVED] my blogspot/blogger blog (this one) not showing any indexed pages in google

i went my blog today, this blog you're reading and copied the URL (without looking at the URL), then typed it into google using the "site:" prefix, to search for my regex posts, but got 0 results.
site:nickhumphreyit.blogspot.no regex

what i didn't notice was the TLD--.no
because when i go to my blog, since i'm in norway, google automatically changes the TLD from .com to .no

when i realized that and tried it again with the .com TLD, then i got the results i was looking for:
site:nickhumphreyit.blogspot.com regex

whew! :)

20130104

how to create a date timestamp in javascript and a sahi script

here's normal javascript code for creating a date timestamp, using double digits for month, day, hour, minute and second, even when the value is between 0-9:

var now = new Date();
var y = now.getFullYear();
var m = now.getMonth()+1; // month is zero based, i.e. january is 0
var d = now.getDate();
var h = now.getHours();
var min = now.getMinutes();
var s = now.getSeconds();
 

alert(y+(m<=9?'0'+m:m)+(d<=9?'0'+d:d)+(h<=9?'0'+h:h)+(min<=9?'0'+min:min)+(s<=9?'0'+s:s));


// OUTPUT format YYYYMMDDHHMMSS, e.g. 20130104090106 (i.e. 2013-01-04 09:01:06)



to do it in sahi, just add the variable sign (dollar sign) in front of the variable names and use " instead of ':

var $now = new Date();
var $y = $now.getFullYear();
var $m = $now.getMonth()+1;
var $d = $now.getDate();
var $h = $now.getHours();
var $min = $now.getMinutes();
var $s = $now.getSeconds();

...

function foo() {
  _setValue(_textbox(67), "DESPATCH_AUTOTEST_" + $y+($m<=9?"0"+$m:$m)+($d<=9?"0"+$d:$d)+($h<=9?"0"+$h:$h)+($min<=9?"0"+$min:$min)+($s<=9?"0"+$s:$s));
}

HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: com.myapp.domainentitiesEJB3.member.Member.users

here's how i write my set methods in my EJB3 java entity objects when a collection is to be set and hibernate is used for persistence:

    public void setUsers(List<RbacUser> users_) {
        if (users == null) users = new ArrayList<RbacUser>();
        users.clear();
        if(users_ != null && !users_.isEmpty()) users.addAll(users_);
    }


if you try to write it like this:
    public void setUsers(List<RbacUser> users_) {
        users = users_;
    }


hibernate may give you an error like this:
HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: com.myapp.domainentitiesEJB3.member.Member.users