Pretty Urls turns ugly when i click commandbutton without immediate attribute.

Splash Forums PrettyFaces Users Pretty Urls turns ugly when i click commandbutton without immediate attribute.

This topic contains 6 replies, has 2 voices, and was last updated by  caglar 2 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #18358

    caglar
    Participant

    Hello; first of all, i’m new to java and jsf. i’m using jsf 2.1.1, Prettyfaces 3.3.2 and Primefaces 3.0.M4.

    Here is the summary of my code:

    pretty-config.xml :

    <url-mapping id=”question”>

    <pattern value=”/question/#{question}” />

    <view-id value=”/faces/questions/question.xhtml” />

    </url-mapping>

    summary of question.xhtml:

    <f:metadata>

    <f:viewParam name=”question” value=”#{questionBean.selectedQuestion}”

    converter=”questionConverter” />

    </f:metadata>

    <h:form id=”form”>

    <div id=”question”>

    ………………

    </div>

    <div id=”writeanswer”>

    <p:editor value=”#{questionBean.answer}” width=”920″ required=”true”

    requiredMessage=”fgfgfgfgf”

    validatorMessage=”fgfgf” immediate=”true”>

    <f:validateLength maximum=”6000″ />

    </p:editor>

    <p:commandButton value=”Send” action=”#{questionBean.sendAnswer}” update=”:form” immediate=”true” />

    </div>

    Summary of questionBean:

    private EntityQuestion selectedQuestion;

    private String answer;

    public EntityQuestion getSelectedQuestion() { return selectedQuestion; }

    public void setSelectedQuestion(EntityQuestion newValue) { selectedQuestion = newValue; }

    public String getAnswer() { return answer; }

    public void setAnswer(String newValue) { answer = newValue; }

    public void sendAnswer() {

    ……..

    }

    questionConverter:

    public class QuestionConverter implements Converter {

    public static EntityQuestion question = new EntityQuestion();

    EntityManagerFactory emf = Persistence.createEntityManagerFactory(“ProjectPU”);

    public EntityQuestion getAsObject(FacesContext context, UIComponent component, String value) {

    EntityManager em = emf.createEntityManager();

    Query query = em.createQuery(“SELECT s FROM EntityQuestion s WHERE s.url = :questionUrl”).setParameter(“questionUrl”, value);

    question = (EntityQuestion) query.getSingleResult();

    return question;

    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {

    EntityQuestion s = (EntityQuestion) value;

    return s.getUrl();

    }

    }

    when i open a question page first time everything works well. but when i remove immediate=”true” attribute from commandbutton on question.xhtml and add ajax=”false”, url goes wrong like that: “ProjectName.Question@19c4e4f” when i click. and questionConverter does not work. when i use immediate=”true” attribute, setAnswer setter does not getting called (maybe another problem cause to this but i don’t know and i can’t find !). maybe removing immediate=”true” attribute could be a solution. please help me.

    #22531

    Hmm, nothing comes to mind. It sounds like maybe PrimeFaces is not correctly encoding the URL. Could you post the app and include steps to reproduce the problem, or create a new small sample app with minimal dependencies?

    Thanks,

    Lincoln

    #22532

    caglar
    Participant

    my codes are in CountryBean2.java, country.xhtml and CountryConverter.java files. i use Netbeans 7.0.1, Glassfish 3.1.1 and Mysql 5.5.14. i uploaded all external libraries, project and database. i hope you will import easily.

    https://hotfile.com/dl/155540695/e52a567/Project.rar.html

    #22533

    Hmm. Thank you for uploading! But, I should have just asked you to write a separate app that reproduces the issue without dependencies, sorry. That’s what I need :)

    ~Lincoln

    #22534

    caglar
    Participant

    if you will run the app, i uploded all you need to hotfile. otherwise tomorrow i will write new app without using database and jpa. as i said, my issue is in CountryBean2.java, country.xhtml and CountryConverter.java. you can see these files in sampleproject.zip

    #22535

    Please do, thanks so much!

    #22536

    caglar
    Participant

    sorry for the late response, i was busy. i created new question class with simple java class, everything works well but is not working with Entity objects. did anybody try clean urls with jpa like as this sample ?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Comments are closed.