0

I read several tutorial about RESTful Web Services and I understood main target of it. But I don't understand how combine REST and xhtml pages.

Usually, I have pages like this

<h:form>
<p:tabView orientation="left" id="mainTabId">
 <p:tab title="User information">
  <h:panelGrid columns="2" columnClasses="column" cellpadding="5"
   styleClass="dataTableStyle" border="2" cellspacing="5">
   <h:outputLabel value="First name:" />
   <p:inputText id="firstName" value="#{user.firstName}"
    validatorMessage="Length should be 3 or more" required="true"
    requiredMessage="This field can not be empty">
    <p:ajax event="mouseout" update="firstNameMsg"></p:ajax>
    <f:validateLength minimum="3"></f:validateLength>
   </p:inputText>
   <p:message id="firstNameMsg" for="firstName" />
   <f:facet name="footer">
    <p:commandButton id="brnId" value="Save changes"
     icon="ui-icon-document" action="saveFuckingData"
     onstart="statusDialog.show()" onsuccess="statusDialog.hide()" />
   </f:facet>
  </h:panelGrid>
 </p:tab>
</p:tabView>
</h:form>

In this case, I have static page that I dynamically fill.

How can I get similar page via REST Api? Should I return whole web page in Java method?

I mean, I know how get JSON/XML via request. But then my web page will look like:

<SubjectsList>
  <subject>
    <coef>4</coef>
    <name>Some data</name>
    <score>71</score>
  </subject>
</SubjectsList>

But I need page that contains many buttons, tables, text fields and other elements, not only JSON/XML text presentation.
I hope you understand what I want)

Bohdan Z.
  • 320
  • 2
  • 4
  • 22
  • You're clearly not understanding "main target" of REST web services. This question just doesn't make any sense. – BalusC Jun 20 '15 at 06:47
  • @BalusC, I mean, should I retrieve whole `HTML` page from `REST Api` or I can somehow fill existing page? – Bohdan Z. Jun 20 '15 at 06:57
  • Is this acceptable as dupe? http://stackoverflow.com/questions/29982657/how-to-implement-jax-rs-restful-service-in-jsf-framework/ Or does the answer need clarification? If so what exactly? – BalusC Jun 20 '15 at 07:07
  • @BalusC, It gives some answers but I have another question. For example: I have `html` page (there are `buttons`, `inputs` and another `nor JSF` components). I have `REST api` that return some object. My question is: Can I change `HTML` content with help of `REST` api? – Bohdan Z. Jun 20 '15 at 07:47
  • _"My question is: Can I change HTML content with help of REST api?"_: yes – Kukeltje Jun 20 '15 at 13:44
  • @Kukeltje, can you give me example where this is done? I don't know how should look client-side of RESTful WS and how change it :( – Bohdan Z. Jun 20 '15 at 14:36
  • Restful WS in java is calls jax-rs. The full thing is called ajax. Search for those terms in google and jackpot – Kukeltje Jun 20 '15 at 18:10

0 Answers0