Следвам примера на <p:datatable>
функцията за динамични колони в витрина на primefaces и работи чудесно.
Сега това, което искам, е да поставя вместо прости <h:outputText>
колони, искам да поставя колони с <p:graphicImage>
, вложени в <p:commanLink>
, което служи за показване на <p:dialogue>
.
с други думи как мога да използвам това:
<f:facet name="header">
#{column.header}
</f:facet>
#{car[column.property]}
</p:columns>
за да го накарате да генерира нещо като това:
<p:column headerText="R"
style=" text-align: center;"
width="10"
rendered="true">
<p:commandLink id="MRepShowButton" update=":form1:display" onclick="EditorDialog.show();" title="Editer le compte rendu">
<f:setPropertyActionListener value="#{exam}" target="#{dyna.selectedExamen}" />
<p:graphicImage id="img1" value="/images/study_Report_icons/Text/0.png" rendered="#{exam.examen.rapport.rapportWrittenState == null}"/>
<p:graphicImage id="img2" value="/images/study_Report_icons/Text/#{exam.examen.rapport.rapportWrittenState}.png" rendered="#{exam.examen.rapport.rapportWrittenState != null}"/>
</p:commandLink>
</p:column>
Само за да ви уведомя, че мога програмно да го направя така:
column.setWidth(String.valueOf(columnmodel.get(i).getWidth() - widthOptimizer));
CommandLink rapstatelink = (CommandLink) application.createComponent(CommandLink.COMPONENT_TYPE);
rapstatelink.setId("MRepShowButton");
rapstatelink.setTitle("Editer le rapport du patient");
rapstatelink.setUpdate(":formero");
rapstatelink.setOnclick("EditorDialog.show();");
ValueExpression value = ef.createValueExpression(elc, "#{exam}", Cotation.class);
ValueExpression target = ef.createValueExpression(elc, "#{dyna.selectedExamen}", Cotation.class);
rapstatelink.addActionListener(new SetPropertyActionListenerImpl(target, value));
ValueExpression value1 = ef.createValueExpression(elc, "#{dyna.toHTML(dyna.selectedExamen.examen.rapport.rapportWrittenFile)}", String.class);
ValueExpression target1 = ef.createValueExpression(elc, "#{dyna.html}", String.class);
rapstatelink.addActionListener(new SetPropertyActionListenerImpl(target1, value1));
GraphicImage rapstateimage = (GraphicImage) application.createComponent(GraphicImage.COMPONENT_TYPE);
rapstateimage.setId("img1");
ValueExpression show1 = ef.createValueExpression(elc, "#{exam.examen.rapport.rapportWrittenState == null}", Boolean.class);
rapstateimage.setValueExpression("rendered", show1);
rapstateimage.setValue("/images/study_Report_icons/Text/0.png");
rapstatelink.getChildren().add(rapstateimage);
GraphicImage rapstateimage2 = (GraphicImage) application.createComponent(GraphicImage.COMPONENT_TYPE);
rapstateimage2.setId("img2");
ValueExpression patsategraphExp = ef.createValueExpression(elc, "/images/study_Report_icons/Text/#{exam.examen.rapport.rapportWrittenState}.png", Object.class);
rapstateimage2.setValueExpression("value", patsategraphExp);
ValueExpression show2 = ef.createValueExpression(elc, "#{exam.examen.rapport.rapportWrittenState != null}", Boolean.class);
rapstateimage2.setValueExpression("rendered", show2);
column.setStyleClass("imagero");
rapstatelink.getChildren().add(rapstateimage2);
column.getChildren().add(rapstatelink);
table.getChildren().add(column);
*този подход за създаване на цялата таблица с данни в bean bean и свързването й с facelet работи с основен проблем, който е, че трябва да щракна два пъти върху командната връзка, за да задействам действието. (няма вложени форми и всичко е съвместимо с Отговор на BalusC).
Допълнителна информация: Primefaces 4.0. JSF 2.2.
<p:commandLink/>
в този случай? Ако не, уведомете ни. Тук имам пример с<p:commandButton>
, но първо трябва да знам дали<p:commandLink/>
е задължително. - person VulfCompressor   schedule 26.12.2013